Mulesoft-CXF WSDL-First Web服务错误

时间:2014-09-12 03:51:26

标签: web-services soap wsdl runtime-error mule-studio

全部,    我在AnyPoint Studio中开发合同优先的SOAP Web服务时遇到了问题(2014年7月,在max OS X上使用Muleserver 3.5.1,JDK 7)。我的流程是:

  1. 手工创建WSDL(为简单起见,在WSDL中嵌入了XML Schema)
  2. 在Anypoint中创建同步HTTP流程
  3. 从WSDL生成Java类(没有错误,工作正常)
  4. 从IDE内部启动Flow(没有错误,工作正常)。
  5. 导入WSDL并在SOAPUI中生成SOAP请求(没有错误,工作正常)
  6. 调用SOAP请求
  7. 此时我在编组SOAP请求时遇到以下错误(我的流没有后端逻辑并且会失败 - 但这不是问题):

     org.apache.cxf.phase.PhaseInterceptorChain: Interceptor for {http://login.demo/}LoginServiceService has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: Message part {urn:MYNAMESPACE}requestParms was not recognized.  (Does it exist in service WSDL?)
        at org.apache.cxf.interceptor.DocLiteralInInterceptor.validatePart(DocLiteralInInterceptor.java:231)
        at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:201)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
        at org.mule.module.cxf.CxfInboundMessageProcessor.sendToDestination(CxfInboundMessageProcessor.java:338)
    

    我的WSDL:

    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="urn:MYNAMESPACE"
    xmlns:tns="urn:MYNAMESPACE"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    
    <wsdl:types>
        <xs:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            targetNamespace="urn:MYNAMESPACE"
            xmlns="urn:MYNAMESPACE"
            elementFormDefault="unqualified" attributeFormDefault="unqualified">
    
            <xs:element name="requestParms" type="LoginRequestType" />
            <xs:element name="responseParms" type="LoginResponseType"/>
    
            <xs:complexType name="LoginRequestType">
                <xs:sequence>
                    <xs:element name="username" type="xs:string"/>
                    <xs:element name="password" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
    
            <xs:complexType name="LoginResponseType">
                <xs:sequence>
                    <xs:element name="success" type="xs:boolean"/>
                    <xs:element name="authenticatedToken" type="xs:string"/>
                </xs:sequence>
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    
    
    <!-- MESSAGES -->
    <wsdl:message name="LoginRequest">
        <wsdl:part name="parameters" element="tns:requestParms"/>
    </wsdl:message>
    
    <wsdl:message name="LoginResponse">
        <wsdl:part name="parameters" element="tns:responseParms"/>
    </wsdl:message>
    
    <!-- WSDL Port Types -->
    <wsdl:portType name="AuthenticatePortType">
        <wsdl:operation name="login">
            <wsdl:input message="tns:LoginRequest"/>
            <wsdl:output message="tns:LoginResponse"/>
        </wsdl:operation>
    </wsdl:portType>
    
    <!-- WSDL Bindings -->
    <wsdl:binding name="AuthenticateBinding" type="tns:AuthenticatePortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="login">
            <soap:operation soapAction="login"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    
    <!-- WSDL Services -->
    <wsdl:service name="LoginService">
        <wsdl:port name="LoginPort" binding="tns:AuthenticateBinding">
            <soap:address location="http://localhost:8081/demo"/>
        </wsdl:port>
    </wsdl:service>
    

    My Mule Config XML:

    <http:endpoint exchange-pattern="request-response" host="localhost" port="8081" method="POST" name="HTTP" doc:name="HTTP"/>
    <flow name="loginFlow" doc:name="loginFlow" initialState="started">
      <http:inbound-endpoint exchange-pattern="request-response"  path="demo" doc:name="Demo" host="localhost" port="8081"/>
      <cxf:jaxws-service  doc:name="CXF" validationEnabled="true" serviceClass="demo.login.LoginService"/>     
    </flow>
    

    我的SOAP请求:

    <soapenv:Envelope xmlns:ns="urn:MYNAMESPACE"
                      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" >
       <soapenv:Header/>
       <soapenv:Body>
          <ns:requestParms>
             <username>aa</username>
             <password>bb</password>
          </ns:requestParms>
       </soapenv:Body>
    </soapenv:Envelope>
    

    另外,我还没有修改生成的java代码(我假设在Anypoint中的wsdl2java) - 只需运行它。

    有什么建议吗?

0 个答案:

没有答案