java SOAP 响应问题
我正在从 jax-ws java 客户端调用 Web 服务,当我收到响应时,我收到一个异常,指出不支持内容类型,
异常跟踪如下。
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: application/soap+xml Supported ones are: [text/xml]
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:295)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:129)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:360)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:187)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:94)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:116)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439)
at com.sun.xml.ws.client.Stub.process(Stub.java:222)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
我检查了soap请求中的标头,它显示可接受的内容类型是html/xml、text/jpg等,但不是application/xml+soap。
使用 SoapUI 进行测试时,一切正常。
我们正在使用 SOAP v1.1..但是(显然)客户端正在使用 SOAP 1.2..我们有办法解析响应吗?
I'm calling a web service from a jax-ws java client, when i recieve a response i get an exception saying that the content-type isn't supported,
the exception trace is as follows.
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: application/soap+xml Supported ones are: [text/xml]
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:295)
at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:129)
at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:360)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:187)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:94)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:116)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:598)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:557)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:542)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:439)
at com.sun.xml.ws.client.Stub.process(Stub.java:222)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:135)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:109)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
I have checked the headers in the soap request, it shows that the acceptable content-types are html/xml, text/jpg etc.. but not application/xml+soap.
when testing with SoapUI, things work perfectly.
we are using SOAP v1.1.. but (clearly) the client is using SOAP 1.2.. is there a way for us to parse the response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用 Maven 作为构建工具,请务必检查您的 Maven 目标是否有 XSoap1.2 作为协议。我们有一个类似的问题,我们几个星期都无法解决。
希望这对您有帮助...
if you are using maven as a build tool, be sure to check your maven goal has XSoap1.2 as a protocol.. we had a similar issue we couldn't figure it out for weeks..
hope this helps you...
摘自 其他人
也许您正在尝试使用错误的 SOAP 版本。
Glassfish 还有一个 SOAP 1.2 页面来提供帮助。
Extrated from someone else
Maybe you are trying to use the wrong SOAP version.
Glassfish also has a SOAP 1.2 page to help.
您可以从
sun- jaxws.xml
。You could remove
binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"
from endpoint definition in thesun-jaxws.xml
.抱歉重新提出这么老的问题。
我只是想添加一些关于为什么 SOAP v1.1 服务器不可能(至少在理论上)接受除
text/xml
之外的其他 MIME 的信息。W3C 上有关 SOAP v1.1 的文档 (§6) 指出
如果我们查看最新的 SOAP v1.2 (§1.3) 文档 我们发现的是:
我认为一个不错的尝试可能是添加实现 SOAP v1.2 的等效服务并逐渐切换到这个新服务。在绝大多数情况下,开关会“正常工作”
Sorry for re-opening such an old question.
I just want to add some more datail about WHY it should not be possible (at least in theory) to accept other MIMEs other than
text/xml
with a SOAP v1.1 server.The documentation about SOAP v1.1 on W3C (§6) states that
While if we look at the most recent documentation of SOAP v1.2 (§1.3) what we find is:
I think that a nice try could be to add an equivalent service implementing SOAP v1.2 and gradually switch to this new one. In the vast majority of cases the switch would "just work"