java
  • spring
  • web-services
  • soap
  • wsdl
  • 2017-02-22 3 views 0 likes 
    0

    1つのWSDLファイルから1つのスープWebサービスを使用する必要があります。これを解決するには​​とmaven-jaxb2-pluginを使います。 WSサーバーは、1つの古いSOAP契約を使用することがあります。私は<soap:operation soapAction="" style="rpc"/>のようなものをWSDLファイルに見つける。 WSDLファイル:spring WSは、古いWSコントラクトで "request"を持つリクエストプロパティをラップする必要があります。

    <?xml version='1.0' encoding='UTF-8'?><wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  xmlns:tns="http://impl.sub.xxx.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http"  name="hahaPaymentWSImpl" targetNamespace="http://impl.sub.xxx.com/"> 
        <wsdl:types> 
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://impl.sub.xxx.com/" targetNamespace="http://impl.sub.xxx.com/" version="1.0"> 
    
        <xs:complexType name="singlePaymentRequest"> 
        <xs:sequence> 
         <xs:element minOccurs="0" name="accountName" type="xs:string"/> 
        </xs:sequence> 
        </xs:complexType> 
    
        <xs:complexType name="singlePaymentResponse"> 
        <xs:sequence> 
         <xs:element minOccurs="0" name="amount" type="xs:double"/> 
        </xs:sequence> 
        </xs:complexType> 
    
    </xs:schema> 
    
        </wsdl:types> 
    
        <wsdl:message name="singlePayment"> 
        <wsdl:part name="request" type="tns:singlePaymentRequest"> 
        </wsdl:part> 
        </wsdl:message> 
        <wsdl:message name="singlePaymentResponse"> 
        <wsdl:part name="return" type="tns:singlePaymentResponse"> 
        </wsdl:part> 
        </wsdl:message> 
    
        <wsdl:portType name="hahaPaymentWS"> 
        <wsdl:operation name="singlePayment"> 
         <wsdl:input message="tns:singlePayment" name="singlePayment"> 
        </wsdl:input> 
         <wsdl:output message="tns:singlePaymentResponse" name="singlePaymentResponse"> 
        </wsdl:output> 
        </wsdl:operation> 
        </wsdl:portType> 
    
        <wsdl:binding name="hahaPaymentWSImplSoapBinding" type="tns:hahaPaymentWS"> 
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> 
        <wsdl:operation name="singlePayment"> 
         <soap:operation soapAction="" style="rpc"/> 
         <wsdl:input name="singlePayment"> 
         <soap:body namespace="http://impl.sub.xxx.com/" use="literal"/> 
         </wsdl:input> 
         <wsdl:output name="singlePaymentResponse"> 
         <soap:body namespace="http://impl.sub.xxx.com/" use="literal"/> 
         </wsdl:output> 
        </wsdl:operation> 
        </wsdl:binding> 
    
        <wsdl:service name="hahaPaymentWSImpl"> 
        <wsdl:port binding="tns:hahaPaymentWSImplSoapBinding" name="hahaPaymentWSPort"> 
         <soap:address location="http://999.00.837.212:8888/services/hahaPaymentWS"/> 
        </wsdl:port> 
        </wsdl:service> 
    </wsdl:definitions> 
    

    初めて、maven-jaxb2-plugin自動WSDLファイルからのJava Beanを生成します。しかし、@XmlRootElementというタグはありません。だから私は手動で<xs:complexType><xs:element>でWSDLファイルに埋めます。そして、それは動作します。

    次に、サーバーにリクエストを送信します。それはFound element accountName but could not find matching RPC/Literal partと伝えます。 soupUI<request>タグと要求プロパティをラップするという理由だけで、私はsoupUIが動作することができます見つける

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
        <SOAP-ENV:Header/> 
        <SOAP-ENV:Body> 
         <ns3:singlePayment xmlns:ns3="http://impl.sub.xxx.com/"> 
         <accountName>xxx</accountName> 
         </ns3:singlePayment> 
        </SOAP-ENV:Body> 
    </SOAP-ENV:Envelope> 
    

    、::このようなログに要求私が知りたい

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
        <SOAP-ENV:Header/> 
        <SOAP-ENV:Body> 
         <ns3:singlePayment xmlns:ns3="http://impl.sub.xxx.com/"> 
    <request> 
         <accountName>xxx</accountName> 
    </request> 
         </ns3:singlePayment> 
        </SOAP-ENV:Body> 
    </SOAP-ENV:Envelope> 
    

    は、サーバ契約のこの問題の1つですか?どうすれば簡単に解決できますか?

    答えて

    0

    wsimport JDKを保存します。
    ステップ1、javaファイルを生成します。

    wsimport -keep -verbose http://xxxx/xxx.wsdl 
    

    ステップ2は、突出して起動するためにファイルをコピーします。

    ObjectFactory objectFactory = new ObjectFactory(); 
    SinglePaymentRequest request = objectFactory.createSinglePaymentRequest(); 
    request.setAccountFlag("0"); 
    hahaPaymentWS hahaPaymentWS = new hahaPaymentWSImpl().gethahaPaymentWSPort(); 
    SinglePaymentResponse response = hahaPaymentWS.singlePayment(request); 
    System.out.println(JSON.toJSONString(response)); 
    

    は私が​​とmaven-jaxb2-plugin古いSOAP契約との互換性の問題があると思います。

    関連する問題