JAX WS with com.sun.net.HttpServer and .net

…衆ロ難τιáo~ 提交于 2020-01-03 04:49:06

问题


I have a very frustrating problem. I have a web service created with JAX WS annotations and Endpoint.publish(...) trick. Of course, it uses com.sun.net.HttpServer. When I try to add a service reference in Visual studio, it won't budge. The server says:

unsupportent content-type: accepted only text/xml

But .net asks with application/soap+xml content-type.

How do i change the content-type in jax ws? Or, how do i change the content type of visual studio add reference thingy.

Thank you. It's very frustrating!


回答1:


After googling i found...

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. Hope this helps :)

EDIT: try the below annotations...

@WebService 
@BindingType(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) 

OR

Endpoint endpoint = Endpoint.create("http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/", impl); 
endpoint.publish("http://localhost:9080/PatientDiscovery"); 


来源:https://stackoverflow.com/questions/4648647/jax-ws-with-com-sun-net-httpserver-and-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!