我在 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 和请求/响应内容,但我认为这里没有必要。