简体   繁体   中英

SOAP client using wsdl2java and Apache CXF

I ran wsdl2java command using Apache CXF codegen plugin. Excerpt from my WSDL:

<!-- submitSMSv3 -->
  <message name="submitSMSv3">
    <part name="parameters" element="tns:submitSMSv3"></part>
    <!--<part name="gdspHeader" element="tns:gdspHeader"></part>-->
  </message>
  <message name="submitSMSv3Response">
    <part name="result" element="tns:submitSMSv3Response"></part>
  </message>
  <portType name="SMSv3">
    <jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
      <jaxws:enableWrapperStyle>true</jaxws:enableWrapperStyle>
    </jaxws:bindings>
    <operation name="SubmitSMSv3" parameterOrder="parameters">
      <input message="tns:submitSMSv3"></input>
      <output message="tns:submitSMSv3Response"></output>
    </operation>
  </portType>
  <binding name="SubmitSMSv3PortBinding" type="tns:SMSv3">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
    <operation name="SubmitSMSv3">
      <soap:operation soapAction=""></soap:operation>
      <input>
        <soap:body use="literal" parts="parameters"></soap:body>
        <!--<soap:header message="tns:submitSMSv3" part="gdspHeader" use="literal"></soap:header>-->
      </input>
      <output>
        <soap:body use="literal"></soap:body>
      </output>
    </operation>
  </binding>
  <service name="SubmitSMSv3Service">
    <port name="SubmitSMSv3Port" binding="tns:SubmitSMSv3PortBinding">
      <soap:address location="http://localhost:${HttpDefaultPort}/GDSPWebServices/SMSv3Service"></soap:address>
    </port>
  </service>

When I invoke the service, my SOAP body looks like this:

<soap:Body>
    <ns1:submitSMSv3 xmlns:ns1="http://ws.gdsp.vodafone.com/">
        <ns2:arg0 xmlns:ns2="http://ws.gdsp.vodafone.com/">
            <deviceId>xxxxxx</deviceId>
            <messageData></messageData>
            <messageType>Text</messageType>
        </ns2:arg0>
    </ns1:submitSMSv3>
</soap:Body>

But I don't want the code as it fails the web call, I want my soap body to look like this instead:

 <soap:Body>
        <ns1:submitSMSv3 xmlns:ns1="http://ws.gdsp.vodafone.com/">
                <deviceId>xxxxxxx</deviceId>
                <messageData></messageData>
                <messageType>Text</messageType>
        </ns1:submitSMSv3>
    </soap:Body>

I'm not sure what to do in order to get it to be this way as I know this way works.

after many of difficulties with the POJO messaging format, I opted to use PAYLOAD and now everything is working as designed. I had to add a processor for the request and the response but it now works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM