1
我已經在Tomcat上部署了一個示例Spring-WS WebService。我可以成功地與Java客戶端調用它,但是當我試圖用一個雅司客戶:Yaws SOAP客戶端內容類型
Wsdl = yaws_soap_lib:initModel("http://localhost:8080/EncryptionService/holiday.wsdl").
yaws_soap_lib:call(Wsdl, "Holiday", [], [{'p:HolidayRequest', [], "aaa"}]).
我得到了一個服務器端異常:
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [spring-ws] in context with path [/EncryptionService] threw exception [Request processing failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create message from InputStream: Invalid Content-Type:application/xml. Is this an error message instead of a SOAP response?; nested exception is com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:application/xml. Is this an error message instead of a SOAP response?] with root cause
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:application/xml. Is this an error message instead of a SOAP response?
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.identifyContentType(MessageImpl.java:602)
at com.sun.xml.internal.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:275)
at com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl.<init>(Message1_1Impl.java:67)
at
(...)
當我相比,Java和雅司病HTTP請求,第一個具有「Content-Type:text/xml; charset = utf-8」,而第二個:「Content-Type:application/xml; charset = utf-8」。然而,在yaws_soap_lib.erl源文件,內容類型似乎是硬編碼:
make_request_body(Content, []) ->
{"application/xml; charset=utf-8",
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"++ Content};
make_request_body(Content, AttachedFiles) ->
{"application/dime",
yaws_dime:encode("<?xml version=\"1.0\" encoding=\"utf-8\"?>" ++ Content,
AttachedFiles)}.
當我改變了爲「text/xml」的並重新編譯,將雅司客戶端工作正常。
有沒有辦法讓客戶端在不改變源代碼的情況下工作?
我可以附加WSDL和請求/響應內容,但我認爲這不是必要的。