Announcement Announcement Module
No announcement yet.
Spring WS Client - Invocation Issue Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring WS Client - Invocation Issue


    I am having hard time getting to run a sample app using Sping WS for invoking a public Web service. I keep getting SOAP Action Header Exception or xml not being well formed exception. Here is my client


    import ate;
    import iceGatewaySupport;
    import Sender;

    public class WebServiceClient extends WebServiceGatewaySupport{

    private static final String uszipInput="<GetInfoByZIP><USZip>60148</USZip></GetInfoByZIP>";
    // private static final String uszipInput="<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"\" xmlns:xsd=\"\" xmlns:soap=\"\"> <soap:Body> <GetInfoByZIP xmlns=\"http://www.webserviceX.NET\"> <USZip>string</USZip> </GetInfoByZIP> </soap:Body></soap:Envelope>";

    // send to the configured default URI
    public void simpleSendAndReceive() {

    StreamSource source = new StreamSource(new StringReader(uszipInput));
    StreamResult result = new StreamResult(System.out);
    getWebServiceTemplate().sendSourceAndReceiveToResu lt(source, result);


    Here is my applicationContext.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "">

    <beans default-autowire="byName">
    <bean id="webServiceClient" class="WebServiceClient">
    <property name="defaultUri" value=""/>

    And I am trying to invoke the GetInfoByZip operation on the web server. I am able to run this using the JaxRpcPortProxyFactoryBean approach.

    Thank you for your help !

  • #2
    The reference documentation contains a section about setting the SOAPAction header on the client, see


    • #3

      Thanks for the reference. It did help me overcome the SOAPActionHeader problem
      I changed my client now

      String uszipInput="<?xml version = \"1.0\" encoding = \"utf-8\"?><GetInfoByZIP><USZip>60148</USZip></GetInfoByZIP>";
      source = new StreamSource(new StringReader(uszipInput));
      StreamResult result = new StreamResult(System.out);
      new SoapActionCallback("http://www.webserviceX.NET/GetInfoByZIP"),

      And I also modified my applicationContext.xml to include a messageSender

      <bean id="webServiceTemplate"
      class=" ceTemplate">
      <property name="defaultUri"
      value="" />
      <property name="messageSender">
      class=" rlConnectionMessageSender" />


      But now, I am able to make the webservice invocation but somehow the input gets lost and webservice does not return any thing.


      • #4
        Are you sure it doesn't return something? You can use a tool like tcpmon to verify what is sent over the wire. See


        • #5
          Hi Arjen,

          I used tcpmon to monitor webservice request and looks like the request is going fine and the HTTP response is also seems to OK but just that the results are not what expect when that web service is invoked directly from the browser.
          For instance, here are the request/response as seen from tcpmon

          POST /uszip.asmx HTTP/1.1
          Accept-Encoding: gzip
          SOAPAction: "http://www.webserviceX.NET/GetInfoByZIP"
          Content-Type: text/xml
          Cache-Control: no-cache
          Pragma: no-cache
          User-Agent: Java/1.5.0_13
          Host: localhost:8080
          Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
          Connection: keep-alive
          Content-Length: 272

          <soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi=""><soapenv:Body><GetInfoByZIP><USZip>60148 </USZip></GetInfoByZIP></soapenv:Body></soapenv:Envelope>

          HTTP/1.1 200 OK
          Date: Sun, 03 Feb 2008 16:26:34 GMT
          Server: Microsoft-IIS/6.0
          X-Powered-By: ASP.NET
          X-AspNet-Version: 1.1.4322
          Cache-Control: private, max-age=0
          Content-Type: text/xml; charset=utf-8
          Content-Length: 305

          <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd=""><soap:Body><GetInfoByZIPResponse xmlns="http://www.webserviceX.NET" /></soap:Body></soap:Envelope>

          Expected reponse is

          <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd=""><soap:Body><GetInfoByZIPResponse xmlns="http://www.webserviceX.NET" />
          <?xml version="1.0" encoding="utf-8" ?>



          • #6
            Hi Coolj,

            I tried the Web Service call u were trying..I see the mistake ur doing is not using the Namespace in your XML Request.

            ie. instead of doing this..

            String uszipInput="<?xml version = \"1.0\" encoding = \"utf-8\"?><GetInfoByZIP><USZip>60148</USZip></GetInfoByZIP>";

            U need to be doing the below..and it works..If u try the above...u are getting empty ur not seeing anything..

            String uszipInput="<?xml version = \"1.0\" encoding = \"utf-8\"?><GetInfoByZIP xmlns="http://www.webserviceX.NET">><USZip>60148</USZip></GetInfoByZIP>";

            If u look at the Soap Request in the URL..u will see the namespace is being expected as part of the request.


            • #7
              Hi Arjen,

              I have a question for u...I am trying to use a web service which is close to the Web Service that is being talked about in this chain but there is small difference..

              The request Soap XML is like this...

              <?xml version="1.0" encoding="utf-8"?>
              <soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap="">
              <GetInfoByState xmlns="http://www.webserviceX.NET/">

              If you observe, the namespace has additional slash ie.. xmlns="http://www.webserviceX.NET/"> When I try such a web service call, I am running into WebServiceTransform Exception..

              How do I handle such scenarios in the WebService Client Call???

              Appreciate your help in advance.