node-soap icon indicating copy to clipboard operation
node-soap copied to clipboard

Response encoding and content-type

Open 0x80 opened this issue 14 years ago • 5 comments

When my soap server is called it returns http headers with wrong fields for encoding and content type. It should be "text/xml" and UTF-8. How and where can i fix this? Here's some logging of the server calling my service. The outbound message is sent en inbound is what node soap returns.


 INFO 20120215 16:55:26 AbstractLoggingInterceptor.java:178- Outbound Message
---------------------------
ID: 437
Address: http://localhost:9096/mediaprocessor/video_transcoder
Encoding: UTF-8
Content-Type: text/xml
Headers: {Accept=[*/*], SOAPAction=["http://mydomain.nl/mediaprocessor/#getStatus"]}
Payload: <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getStatus xmlns:ns2="urn://mediaprocessor.service.mydomain.nl"/>
   </soap:Body>
</soap:Envelope>

--------------------------------------
 INFO 20120215 16:55:26 AbstractLoggingInterceptor.java:178- Inbound Message
----------------------------
ID: 437
Response-Code: 200
Encoding: ISO-8859-1
Content-Type: 
Headers: {connection=[keep-alive], transfer-encoding=[chunked]}
Payload: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns:GetStatusResponse xmlns:ns="urn://mediaprocessor.service.mydomain.nl"><status>STATUS_OK</status><message>Default processor response</message></ns:GetStatusResponse></soap:Body></soap:Envelope>
--------------------------------------

0x80 avatar Feb 15 '12 16:02 0x80

this looks like a bug in the soap server. thanks for reporting it.

the place to set the response headers is right before line 68 in lib/server.js (before res.write(result)). you should probably use res.setHeader("Content-Type","application/soap+xml") and res.setHeader("Encoding","utf-8").

milewise avatar Feb 15 '12 16:02 milewise

Shouldn't the response headers depend on the request headers? I mean "application/soap+xml" is soap 1.2, and "text/xml" is soap 1.1

If a soap 1.1 request is made I would think a 1.1 response is expected?

Also i see line 42 says "application/xml" for the wsdl. Maybe "text/xml" is better here. I'm no xml expert just noticed it.

0x80 avatar Feb 15 '12 19:02 0x80

@0x80: agree on both points. feel free to submit a patch, otherwise i will try to work on this within the next few weeks (things are really busy for me right now at work). thanks!

milewise avatar Feb 15 '12 19:02 milewise

Thanks I'll do some more testing first tomorrow. I now solved it by setting:

        res.setHeader("Content-Type", "text/xml")
        res.setHeader("Encoding", "UTF-8")

Stangely though only the content type ended up in the http header , and encoding sticked to iso. Will have another look at work tomorrow.

Cheers

0x80 avatar Feb 15 '12 19:02 0x80

Does anyone came up with a solution for this? i kinda have the same issue, and this ticket has like 10 months :'(

Luisreino avatar Nov 26 '12 16:11 Luisreino