Announcement Announcement Module
Collapse
No announcement yet.
JAX B Marshaller & Spring WS Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JAX B Marshaller & Spring WS

    Hi,
    I am using JAX-B (2) as a marshaller for Spring web services (2.5.4) on Tomcat 5.5
    I have a client generated by Axis WSDL2Java
    All my services run perfectly fine and return the data to client.
    There is one service which returns non-english characters.

    Following are request and response SOAP Envelopes
    REQUEST ENVELOPE:
    POST ....
    Content-Type: text/xml; charset=utf-8
    Accept: application/soap+xml, application/dime, multipart/related, text/*
    User-Agent: Axis/1.4
    Host: localhost:9090
    Cache-Control: no-cache
    Pragma: no-cache
    SOAPAction: ""
    Content-Length: 394

    <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv=" xmlns:xsd=".." xmlns:xsi=".."><soapenv:Body><fetchStaticList xmlns=""><key>AccessoryTranslations</key></fetchStaticList></soapenv:Body></soapenv:Envelope>


    RESPOSNE ENV:
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    SOAPAction: ""
    Content-Type: text/xml
    Date: Fri, 18 Jul 2008 14:24:29 GMT
    Connection: close

    <soapenv:Envelope xmlns:soapenv="..." ...soapenv:Body><ns1:fetchStaticListResponse...">< ns1:fetchStaticListReturn><ns1:errorCode xmlns:xsi="..." xsi:nil="true"/><ns1:errorDescription xmlns:xsi="..." xsi:nil="true"/><ns1:status>Success</ns1:status><ns1:accessoryCodes xmlns:xsi="..." xsi:nil="true"/><ns1:accessoryTranslations><ns1:item><ns1:entityC d>Accessories</ns1:entityCd><ns1:languageId>1</ns1:languageId><ns1:languageName>1</ns1:languageName><ns1:text>&#x4100;&#x6300;&#x6900 ;&#x6400;&#x2000;&#x4600;&#x6C00;&#x6100;&#x6E00;& #x6700;&#x6500;</ns1:text><ns1:textCd>ACD</ns1:textCd></ns1:item><ns1:item><ns1:entityCd>Accessories
    ....................


    This is translated as a SOAP Fault on the client side

    Exception in thread "main" AxisFault
    faultCode: {...}
    Server.userException
    faultSubcode:
    faultString: org.xml.sax.SAXParseException: Character reference &quot;&amp;#xDC00&quot; is an invalid XML character.
    faultActor:
    faultNode:
    faultDetail:


    On the server side it displays following message

    java.io.IOException:
    ClientAbortException: java.net.SocketException: Software caused connection abor
    t: socket write error
    at org.apache.catalina.connector.OutputBuffer.realWri teBytes(OutputBuffe
    r.java:366)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteCh unk.java:323)
    at org.apache.catalina.connector.OutputBuffer.writeBy tes(OutputBuffer.ja
    va:392)
    at org.apache.catalina.connector.OutputBuffer.write(O utputBuffer.java:38
    1)
    at org.apache.catalina.connector.CoyoteOutputStream.w rite(CoyoteOutputSt
    ream.java:89)
    at org.springframework.ws.transport.TransportOutputSt ream.write(Transpor
    tOutputStream.java:60)
    at org.apache.axis.utils.ByteArray.writeTo(ByteArray. java:375)
    at org.apache.axis.SOAPPart.writeTo(SOAPPart.java:265 )
    at org.apache.axis.Message.writeTo(Message.java:539)
    at org.springframework.ws.soap.saaj.Saaj12Implementat ion.writeTo(Saaj12I
    mplementation.java:255)
    at org.springframework.ws.soap.saaj.SaajSoapMessage.w riteTo(SaajSoapMess
    age.java:118)
    at org.springframework.ws.transport.AbstractWebServic eConnection.send(Ab
    stractWebServiceConnection.java:42)
    at org.springframework.ws.transport.support.WebServic eMessageReceiverObj
    ectSupport.handleConnection(WebServiceMessageRecei verObjectSupport.java:97)
    at org.springframework.ws.transport.http.WebServiceMe ssageReceiverHandle
    rAdapter.handle(WebServiceMessageReceiverHandlerAd apter.java:57)
    at org.springframework.ws.transport.http.MessageDispa tcherServlet.doServ
    ice(MessageDispatcherServlet.java:197)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(Frame
    workServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServ
    let.java:511)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:710)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(Appl
    icationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationF
    ilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperV
    alve.java:213)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextV
    alve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.j
    ava:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.j
    ava:117)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineVal
    ve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.jav
    a:174)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java
    :874)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.p
    rocessConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpo
    int.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFol
    lowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadP
    ool.java:689)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: java.net.SocketException: Software caused connection abort: socket wr
    ite error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutp utStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStre am.java:136)
    at org.apache.coyote.http11.InternalOutputBuffer.real WriteBytes(Internal
    OutputBuffer.java:747)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(B yteChunk.java:432)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteCh unk.java:347)
    at org.apache.coyote.http11.InternalOutputBuffer$Outp utStreamOutputBuffe
    r.doWrite(InternalOutputBuffer.java:770)
    at org.apache.coyote.http11.filters.IdentityOutputFil ter.doWrite(Identit
    yOutputFilter.java:127)
    at org.apache.coyote.http11.InternalOutputBuffer.doWr ite(InternalOutputB
    uffer.java:580)
    at org.apache.coyote.Response.doWrite(Response.java:5 60)
    at org.apache.catalina.connector.OutputBuffer.realWri teBytes(OutputBuffe
    r.java:361)


    If I use TCPMon ofcourse the TCPMon prevents being error thrown on server side.

    Does anyone can give me a idea of what is going on here? Do I have to set encoding explicitely on the server side for web services?
    I have already set the client encoding to UTF-8 using
    _call.setProperty(org.apache.axis.client.Call.CHAR ACTER_SET_ENCODING,
    "UTF-8");

    Why response of all service operations which return only english characters is decoded successfully and it fails in case when service returns european characters?
    I think its a Axis client specific problem. But getting no idea how to resolve this

    Can any one please help me on this?

  • #2
    spring-ws jaxb2 encoding issue

    Hi there,

    I have similer issue, We developed spring based webservice 1.5.1, using jaxb2 marshaller for xml, service works good for standard characters. Whenever input xml has chineese character in it then service outputs ??? instead of the original character.
    Client sends UTF-8 we verified that, so we are loosing the characters in spring framework, what i understand from documentation spring-ws by default uses UTF-8. Webservice is deployed on Weblogic 9.2. Any idea what's missing here?

    part of xml input:
    <ns1:subject>城镇荔城大道百花路 test</ns1:subject>

    xml output

    <ns1:subject>????????? test</ns1:subject>

    Spring servlet config file for marshaller:

    <bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">
    <description>
    The JAXB Marshaller is used by the sendToTargetRequest to (un)marshal XML to objects and vice-versa.
    </description>
    <property name="contextPath" value="xx.orders.types:xx.orders.functionalack"/>
    <property name="mtomEnabled" value="false"/>
    <property name="marshallerProperties">
    <map>
    <entry key="jaxb.encoding">
    <value>UTF-8</value>
    </entry>
    </map>
    </property>
    </bean>

    Any help on resolving this encoding issue is highly aprreciated.

    Thanks,
    Shan.

    Comment

    Working...
    X