Announcement Announcement Module
No announcement yet.
Web Service with soap issue Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web Service with soap issue

    Hi guys, I've an unsolved problem and I'm getting crazy working on it. Therefore if someone could help doing me this favor, just check what is wrong. I have this service that works very well if I use SOAP UI as test:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema  xmlns:xs=""
        <xs:element name="client">
                   <xs:element name="id" type="xs:int"/>
                   <xs:element name="first_name" type="xs:string"/>
                   <xs:element name="last_name" type="xs:string"/>
           <xs:element name="customerRequest">
                           <xs:element name="id" type="xs:int"/>
           <xs:element name="customerResponse">
                       <xs:element ref="customer:client"/>
    <context:component-scan base-package="spring.service"/>
        <sws:dynamic-wsdl id="customer"
            <sws:xsd location="/WEB-INF/services/customer.xsd"/>
        <bean id="webServiceTemplate" class="">
            <property name="messageFactory" ref="messageFactory"/>
            <property name="messageSender" ref="messageSender"/>
            <property name="marshaller" ref="msh"/>
            <property name="unmarshaller" ref="msh"/>
            <property name="defaultUri" value="http://localhost/dataTest/services"/>
        <bean id="msh" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <property name="classesToBeBound">
        <bean id="messageFactory" class=""/>
        <bean id="messageSender" class=""/>
    But if I try to develop the client side in this way:

         public Customer doIt(long Id) {
                CustomerRequest customerRequest = new CustomerRequest();
                CustomerResponse customerResponse = (CustomerResponse)
                return customerResponse;
    I got the following response:
    2011-08-30 14:36:50,893 [main] INFO - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
    2011-08-30 14:36:50,895 [main] DEBUG - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
    2011-08-30 14:36:51,449 [main] INFO - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
    2011-08-30 14:36:51,452 [main] DEBUG - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
    2011-08-30 14:36:51,634 [main] INFO - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
    2011-08-30 14:36:51,635 [main] DEBUG - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
    2011-08-30 14:36:51,693 [main] DEBUG - Opening [] to [http://localhost:8080/dataTest/services/]
    2011-08-30 14:36:51,809 [main] DEBUG - Sent request [SaajSoapMessage customerRequest]
    2011-08-30 14:36:52,237 [main] DEBUG - Received error for request [SaajSoapMessage customerRequest]
    which is basically a 404 error, service not found, I guess. I'm really hopeless...

    Thank you in advance

  • #2
    R u behind a proxy?? Can you configure that??


    • #3
      Nop, It's a demo, server and client are on the same pc. I believe that is something wrong with the WebServiceTemplate class, I mean something that I don't know how to configure, though I've been reading the official reference manual for a while, I didn't find out anything useful. I'm still working on it...


      • #4
        Difference Between wrong and right

        I noticed a difference into the log. Below you can see the right response log. In SOAP UI, the testing tool, I have the following request:

        <soapenv:Envelope xmlns:soapenv="" xmlns:ser="http://localhost:8080/dataTest/services/">
        and get the following response:

        <SOAP-ENV:Envelope xmlns:SOAP-ENV="">
        ...obviously the customer name is invented and doesn't have any relevance

        DEBUG - Accepting incoming [] at [http://localhost:8080/dataTest/services/]
        DEBUG - Received request [SaajSoapMessage {http://localhost:8080/dataTest/services/}customerRequest]
        DEBUG - Looking up endpoint for [{http://localhost:8080/dataTest/services/}customerRequest]
        DEBUG - Endpoint mapping [] maps request to endpoint [public spring.schema.CustomerResponse spring.service.CustomerServices.CustomerRequest(org.jdom.Element) throws org.jdom.JDOMException]
        DEBUG - Testing endpoint adapter []
        DEBUG - Marshalling [spring.schema.CustomerResponse@2e06bd] to response payload
        DEBUG - Sent response [SaajSoapMessage customerResponse] for request [SaajSoapMessage {http://localhost:8080/dataTest/services/}customerRequest]
        DEBUG - Successfully completed request
        and this is the log of the wrong version, obtained by the following code:

        public void doIt() {
                    CustomerRequest customerRequest = new CustomerRequest();
                    CustomerResponse customerResponse = (CustomerResponse)
        Wrong version log:

        DEBUG - Accepting incoming [] at [http://localhost:8080/dataTest/services/]
        DEBUG - Received request [SaajSoapMessage customerRequest]
        DEBUG - Looking up endpoint for [customerRequest]
        DEBUG - Endpoint mapping [] has no mapping for request
        DEBUG - Looking up endpoint for []
        DEBUG - Endpoint mapping [] has no mapping for request
        DEBUG - Endpoint mapping [] has no mapping for request
        WARN - No endpoint mapping found for [SaajSoapMessage customerRequest]
        DEBUG - Successfully completed request
        INFO - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
        DEBUG - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
        INFO - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
        DEBUG - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
        DEBUG - Opening [] to [http://localhost:8080/dataTest/services]
        TRACE - Sent request [<SOAP-ENV:Envelope xmlns:SOAP-ENV=""><SOAP-ENV:Header/><SOAP-ENV:Body><customerRequest xmlns=""><id>1</id></customerRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>]
        DEBUG - Received error for request [SaajSoapMessage customerRequest]
        As you can see, the SOAP request body is my customerRequest, but there is something wrong with the xmlns element (<customerRequest xmlns=""><id>1</id></customerRequest>). Infact it should be like <customerRequest xmlns="http://localhost:8080/dataTest/services/"><id>1</id></customerRequest>.
        I really don't have any freaking idea how to get it. I'm using the WebServiceTemplate.marshalSendAndReceive() method with the canonical two arguments, namespace and object, and seems like the problem comes from this method or somewhat related to.

        Clearly it is something wrong with my configuration....but I can't understand where I'm getting wrong.

        Could you please help me...many thanks in advance. See ya
        Last edited by tarebor; Sep 1st, 2011, 02:17 PM.


        • #5

          Problem Solved. It was a Jaxb problem. I fixed it reading the guide at the following address ( It was very inspiring and comprehensible. Now the Log is the following:

          client log

          2011-09-02 08:14:53,116 [main] INFO - Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
          2011-09-02 08:14:53,116 [main] DEBUG - Using MessageFactory class [com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl]
          2011-09-02 08:14:53,429 [main] DEBUG - Opening [] to [http://localhost:8080/dataTest/services/]
          2011-09-02 08:14:53,726 [main] TRACE - Sent request [<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns2="http://localhost:8080/dataTest/services/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:customerRequest xmlns:ns2="http://localhost/dataTest/services/"><ns2:id>5</ns2:id></ns2:customerRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>]
          2011-09-02 08:14:53,951 [main] DEBUG - Received response [SaajSoapMessage {http://localhost/dataTest/services/}customerResponse] for request [SaajSoapMessage {http://localhost/dataTest/services/}customerRequest]
          server log

          2011-09-02 08:14:53,773 [1042586@qtp-6966554-0] DEBUG - Accepting incoming [] at [http://localhost:8080/dataTest/services/]
          2011-09-02 08:14:53,773 [1042586@qtp-6966554-0] DEBUG - Received request [SaajSoapMessage {http://localhost/dataTest/services/}customerRequest]
          2011-09-02 08:14:53,773 [1042586@qtp-6966554-0] DEBUG - Looking up endpoint for [{http://localhost/dataTest/services/}customerRequest]
          2011-09-02 08:14:53,821 [1042586@qtp-6966554-0] DEBUG - Endpoint mapping [] maps request to endpoint [public spring.schema.CustomerResponse spring.service.CustomerServices.customerRequest(org.jdom.Element) throws org.jdom.JDOMException]
          2011-09-02 08:14:53,821 [1042586@qtp-6966554-0] DEBUG - Request: <ns2:customerRequest xmlns:ns2="http://localhost/dataTest/services/"><ns2:id>5</ns2:id></ns2:customerRequest>
          2011-09-02 08:14:53,836 [1042586@qtp-6966554-0] DEBUG - Request: <SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns2="http://localhost:8080/dataTest/services/"><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:customerRequest xmlns:ns2="http://localhost/dataTest/services/"><ns2:id>5</ns2:id></ns2:customerRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
          2011-09-02 08:14:53,836 [1042586@qtp-6966554-0] DEBUG - Request message validated
          2011-09-02 08:14:53,852 [1042586@qtp-6966554-0] DEBUG - Testing endpoint adapter []
          2011-09-02 08:14:53,856 [1042586@qtp-6966554-0] DEBUG - Marshalling [spring.schema.CustomerResponse@188045a] to response payload
          2011-09-02 08:14:53,856 [1042586@qtp-6966554-0] DEBUG - Response message validated
          2011-09-02 08:14:53,856 [1042586@qtp-6966554-0] DEBUG - Response: <SOAP-ENV:Envelope xmlns:SOAP-ENV=""><SOAP-ENV:Header/><SOAP-ENV:Body><ns2:customerResponse xmlns:ns2="http://localhost/dataTest/services/"><ns2:first_name>Fred</ns2:first_name><ns2:last_name>Taylor</ns2:last_name></ns2:customerResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
          2011-09-02 08:14:53,918 [1042586@qtp-6966554-0] DEBUG - Response: <ns2:customerResponse xmlns:ns2="http://localhost/dataTest/services/"><ns2:first_name>Fred</ns2:first_name><ns2:last_name>Taylor</ns2:last_name></ns2:customerResponse>
          2011-09-02 08:14:53,918 [1042586@qtp-6966554-0] DEBUG - Sent response [SaajSoapMessage {http://localhost/dataTest/services/}customerResponse] for request [SaajSoapMessage {http://localhost/dataTest/services/}customerRequest]
          2011-09-02 08:14:53,918 [1042586@qtp-6966554-0] DEBUG - Successfully completed request
          Many thanks


          • #6
            Glad it is working.


            • #7
              Thanks for sharing this interesting post, hope you will share more interesting posts in future too.

              Penny Auctions


              • #8
                a freakin' Jaxb problem, hehe, yap, good to hear its solved ))

                mercedes seattle
                mercedes of seattle


                • #9
                  I've tried this and its working. I'm very glad that I found this script!


                  • #10
                    Thank you! i found this script through google! So lucky!

                    Thiet ke noi that | Noi that van phong | Noi that Hoa Phat | Ban ghe van phong | Trang tri noi that


                    • #11
                      Could you please share the jaxb problem solution i could not find the solution in jaxb-tutorial documentation.
                      i am having the same problem
                      (WebServiceTemplate:661) - Received error for request [SaajSoapMessage {}QueryByMsisdnInput]
                      [16:31:50,919] ERROR (UdmServerWSClientImpl:63) - Exception occured: Not Found [404]
                      [16:31:50,919] ERROR (UdmServerWSClientImpl:63) - Exception occured: Not Found [404]
             xception: Not Found [404]
                      at ate.handleError(
                      at ate.doSendAndReceive(

                      THANKS IN ADVANCE..


                      • #12
                        I apologize elcinsumerkan to answer you now.

                        ok I found out the solution in this way:


                        1) Setting up a MessageDispatcherServlet and remember to set the param name 'transformWsdlLocations' to true;
                        2) Using Spring Web Service Namespace, add <sws:annotation-driven/> <sws:dynamic-wsdl ... /> this configuration depend on
                        your web service.
                        3) After configuring the server side you can fire the following request http://localhost:8080/{app}/orders.wsdl (it's my server address). The dynamic-wsdl configuration will build a WSDL file.
                        4)At this point you can copy the wsdl from the web page or whatever and put it in a static wsdl <sws:static id=".." location="..."/>
                        5)Build up the xsd schema (pay particular attention to the namespace that could be whatever).
                        6)Build up the classes which represent the above schema with the following annotations:
                        @XmlRootElement(name="customerRequest", namespace="")

                        VERY IMPORTANT: Remember to use the notation @XmlElement(namespace="http://....") on each element
                        5) define an objectFactory which allows you to programmatically construct new instances of the Java rappresentation of Xml content using the @XmlRegistry alternatively you can use the property classToBeBound when you...
                        6) ...set up the Marshaller JAX2B.

                        I hope this will help you
                        Last edited by tarebor; Feb 10th, 2012, 03:07 PM.