Announcement Announcement Module
No announcement yet.
Encoding mismatch between request and response Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Encoding mismatch between request and response

    I developed a simple echo service using = 2.0.3.RELEASE, MessageDispatcherServlet, an annotated endpoint without any xml marshalling just jdom(1.1).

    The problem: The request encoding = iso-8859-1 (see Content-Type header and XLM processing instruction below), but the response encoding = UTF-8. I was hoping that the XML response would honor and keep the same encoding used on the request. <Input> [0xbd] = the iso-8859-1 encoded value for the one half character (1/2). <Output> [0xc2][0xbd] = the utf-8 encoded value. The encoded bytes are correct, but obviously different between the request and response. I think the jdom XMLOutputter needs to have its encoding set based on the request's encoding. Can this be done?

    SoapUI http log:
    "POST /spring-echo2-ws/services HTTP/1.1[\r][\n]"
    "Accept-Encoding: gzip,deflate[\r][\n]"
    "Content-Type: text/xml;charset=iso-8859-1[\r][\n]"
    "SOAPAction: Echo[\r][\n]"
    "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
    "Content-Length: 335[\r][\n]"
    "<?xml version="1.0" encoding="ISO-8859-1"?>[\n]"
    "<soapenv:Envelope xmlns:soapenv="" xmlns:wsdl="urn:Connect.EchoService/WSDL">[\n]"
    " <soapenv:Header/>[\n]"
    " <soapenv:Body>[\n]"
    " <wsdl:EchoRequest>[\n]"
    " <wsdl:Input>Aaa [0xbd] aaa</wsdl:Input>[\n]"
    " </wsdl:EchoRequest>[\n]"
    " </soapenv:Body>[\n]"
    "HTTP/1.1 200 OK[\r][\n]"
    "HTTP/1.1 200 OK[\r][\n]"
    "Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2[\r][\n]"
    "SOAPAction: ""[\r][\n]"
    "Content-Type: text/xml; charset=utf-8[\r][\n]"
    "Content-Length: 250[\r][\n]"
    "Server: Jetty(6.1.9)[\r][\n]"
    "<SOAP-ENV:Envelope xmlns:SOAP-ENV=""><SOAP-ENV:Header/><SOAP-ENV:Body><e:EchoResponse xmlns:e="urn:Connect.EchoService/WSDL"><e:Output>Aaa [0xc2][0xbd] aaa</e:Output></e:EchoResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>"

    Here's some code from my annotated WS endpoint:
    import org.jdom.Element;

    public class EchoEndpoint implements InitializingBean {
    @PayloadRoot(localPart = "EchoRequest", namespace = "urn:Connect.EchoService/WSDL")
    public Element processEcho(@RequestPayload Element element) throws Exception ...