我在Tomcat上部署了一个示例Spring-WS WebService。我可以使用Java客户端成功调用它,但是当我尝试使用Yaws客户端时:
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和Yaws 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”并重新编译时,Yaws客户端工作正常。
有没有办法让客户端工作而不更改源代码?
我可以附加WSDL和请求/响应内容,但我认为这不是必需的。