Announcement Announcement Module
Collapse
No announcement yet.
Spring-WS: Response message contains weird characters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring-WS: Response message contains weird characters

    Hi,

    I am new to Spring-WS and I had to create a WebService for my project.
    So to try some examples, I downloaded spring-webservices-samples from http://code.google.com/p/spring-webservices-samples/

    When I deploy the war file and test using SoapUI; I am getting weird characters (like ce,1a,0 ) in the response message
    And there is no exceptions. I tried to debug but no luck.
    Please help me with the issue. I really appreciate any input.

    I am using JBoss 4.2.3, Java 1.6 (64 bit).
    Kindly note: I have attached the WSDL file as CalculatorService_WSDL.txt

    I tried deploying the same war file in Tomcat-7.0.29 and it works. But I have to get my WebService working in JBoss 4.2.3

    Response Captured using TCPMon:

    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)/JBossWeb-2.0
    SOAPAction: ""
    Content-Type: text/xml;charset=UTF-8
    Transfer-Encoding: chunked
    Date: Fri, 20 Jul 2012 01:47:23 GMT

    ce
    <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns2:CalculateResponse xmlns:ns2='http://www.marvelution.com/samples/schemas/CalculatorServiceSchema'/>
    1a
    </env:Body></env:Envelope>
    0


    Request Captured using TCPMon:

    POST /annotated-payload-endpoint/calculatorService HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: text/xml;charset=UTF-8
    SOAPAction: "http://www.marvelution.com/samples/definitions/CalculatorService/Add"
    Content-Length: 377
    Host: 127.0.0.1:9999
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cal="http://www.marvelution.com/samples/schemas/CalculatorServiceSchema">
    <soapenv:Header/>
    <soapenv:Body>
    <cal:Add>
    <!--2 or more repetitions:-->
    <cal:number>1</cal:number>
    <cal:number>2</cal:number>
    </cal:Add>
    </soapenv:Body>
    </soapenv:Envelope>


    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4" id="spring-ws-annotated-payload">

    <display-name>Marvelution.com :: Samples :: Spring-WS :: Annotated Payload Root Endpoint</display-name>

    <servlet>
    <servlet-name>spring-ws</servlet-name>
    <servlet-class>
    org.springframework.ws.transport.http.MessageDispa tcherServlet
    </servlet-class>
    <init-param>
    <param-name>transformWsdlLocations</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>

    <servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>

    </web-app>


    spring-ws-servlet.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <import resource="classpath:applicationContext.xml"/>

    <bean id="calculatorService" class="org.springframework.ws.wsdl.wsdl11.SimpleWs dl11Definition">
    <property name="wsdl" value="WEB-INF/wsdl/CalculatorService.wsdl"/>
    </bean>

    </beans>


    applicationContext.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="calculatorImpl"
    class="com.marvelution.samples.spring.ws.annotated .payload.endpoint.CalculatorImpl" />

    <bean id="objectFactory"
    class="com.marvelution.samples.schemas.calculators erviceschema.ObjectFactory" />

    <bean id="calculatorEndpoint"
    class="com.marvelution.samples.spring.ws.annotated .payload.endpoint.endpoints.CalculatorEndpoint">
    <constructor-arg ref="calculatorImpl" />
    <constructor-arg ref="objectFactory" />
    </bean>

    <bean
    class="org.springframework.ws.server.endpoint.mapp ing.PayloadRootAnnotationMethodEndpointMapping" />

    <bean
    class="org.springframework.ws.server.endpoint.adap ter.GenericMarshallingMethodEndpointAdapter">
    <constructor-arg ref="marshaller" />
    </bean>

    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
    <property name="contextPath" value="com.marvelution.samples.schemas.calculators erviceschema" />
    </bean>

    </beans>


    CalculatorEndpoint.java

    package com.marvelution.samples.spring.ws.annotated.payloa d.endpoint.endpoints;

    import org.springframework.ws.server.endpoint.annotation. Endpoint;
    import org.springframework.ws.server.endpoint.annotation. PayloadRoot;

    import com.marvelution.samples.schemas.calculatorservices chema.Add;
    import com.marvelution.samples.schemas.calculatorservices chema.CalculateResponse;
    import com.marvelution.samples.schemas.calculatorservices chema.Divide;
    import com.marvelution.samples.schemas.calculatorservices chema.Multiply;
    import com.marvelution.samples.schemas.calculatorservices chema.ObjectFactory;
    import com.marvelution.samples.schemas.calculatorservices chema.Subtract;
    import com.marvelution.samples.spring.ws.annotated.payloa d.endpoint.Calculator;

    @Endpoint
    public class CalculatorEndpoint {

    private final Calculator calculator;
    private final ObjectFactory objectFactory;

    public CalculatorEndpoint(Calculator calculator, ObjectFactory objectFactory) {
    this.calculator = calculator;
    this.objectFactory = objectFactory;
    }

    @PayloadRoot(namespace = "http://www.marvelution.com/samples/schemas/CalculatorServiceSchema", localPart = "Add")
    public CalculateResponse add(Add numbers) {
    CalculateResponse res = wrapResult(calculator.add(numbers.getNumber()));
    System.out.println("Response before sending:"+res.getResult());
    return res;
    }

    @PayloadRoot(namespace = "http://www.marvelution.com/samples/schemas/CalculatorServiceSchema", localPart = "Subtract")
    public CalculateResponse subtract(Subtract numbers) {
    return wrapResult(calculator.subtract(numbers.getNumber() ));
    }

    @PayloadRoot(namespace = "http://www.marvelution.com/samples/schemas/CalculatorServiceSchema", localPart = "Divide")
    public CalculateResponse divide(Divide numbers) {
    return wrapResult(calculator.divide(numbers.getNumber())) ;
    }

    @PayloadRoot(namespace = "http://www.marvelution.com/samples/schemas/CalculatorServiceSchema", localPart = "Multiply")
    public CalculateResponse multiply(Multiply numbers) {
    return wrapResult(calculator.multiply(numbers.getNumber() ));
    }

    private CalculateResponse wrapResult(double result) {
    CalculateResponse response = objectFactory.createCalculateResponse();
    response.setResult(result);
    return response;
    }

    }


    List of jars under WEB-INF\lib:

    activation-1.1.jar
    aopalliance-1.0.jar
    commons-logging-1.1.1.jar
    jaxb-api-2.0.jar
    jaxb-impl-2.0.3.jar
    jsr173_api-1.0.jar
    spring-aop-2.5.5.jar
    spring-beans-2.5.5.jar
    spring-context-2.5.5.jar
    spring-context-support-2.5.5.jar
    spring-core-2.5.5.jar
    spring-oxm-1.5.4.jar
    spring-oxm-tiger-1.5.4.jar
    spring-web-2.5.5.jar
    spring-webmvc-2.5.5.jar
    spring-ws-core-1.5.4.jar
    spring-ws-core-tiger-1.5.4.jar
    spring-xml-1.5.4.jar
    wsdl4j-1.6.1.jar

    Thanks
    Jeg
    Last edited by Jeg; Jul 20th, 2012, 10:04 AM.

  • #2
    I found out what the issue was.
    The SAAJ implementation provided by JBoss has some issues. (i.e. This Default JBoss implementation "org.jboss.ws.core.soap.MessageFactoryImpl" has issues)
    The solution is therefore not to use the JBoss implementation, but to use another implementation.

    Example: Use one of the following implementation:
    com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessage Factory1_1Impl
    org.apache.axis2.saaj.MessageFactoryImpl

    <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMe ssageFactory">
    <property name="messageFactory">
    <bean class="org.apache.axis2.saaj.MessageFactoryImpl"/>
    </property>
    </bean>

    This issue already reported here: URL: http://static.springsource.org/sprin...tml#saaj-jboss
    Last edited by Jeg; Aug 11th, 2012, 11:02 AM.

    Comment

    Working...
    X