我有一个非常令人沮丧的问题。我有一个使用 JAX WS 创建的 Web 服务 注释和 Endpoint.publish(...) 技巧。当然,它使用com.sun.net.HttpServer。当我尝试在 Visual Studio 中添加服务引用时,它不会移动。服务器说:
不支持的内容类型:仅接受文本/xml
但是 .net 要求使用 application/soap+xml 内容类型。
如何更改 jax ws 中的内容类型?或者,我如何更改 Visual Studio 添加引用内容的内容类型。
谢谢。真是令人沮丧!
最佳答案
谷歌搜索后我发现......
Hi,
I've resolved the problem.
'application/soap+xml' is the content type used for SOAP 1.2 messages whereas text/xml is used for SOAP 1.1. Hence the client send SOAP 1.2 requests and service expects only SOAP 1.1.
Metro uses SOAP 1.1 by default. How to enable SOAP 1.2 binding is explained here: - http://forums.java.net/jive/thread.jspa?messageID=322894 - https://metro.dev.java.net/1.4/docs/soap12.html
Reference 。希望这有帮助:)
编辑:尝试以下注释...
@WebService
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)
或者
Endpoint endpoint = Endpoint.create("http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/", impl);
endpoint.publish("http://localhost:9080/PatientDiscovery");
关于java - 带有 com.sun.net.HttpServer 和 .net 的 JAX WS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4648647/