java SOAP 响应问题

发布于 2024-11-26 19:25:12 字数 1853 浏览 2 评论 0原文

我正在从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

吲‖鸣 2024-12-03 19:25:12

如果您使用 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...

花想c 2024-12-03 19:25:12

摘自 其他人

  The @BindingType annotation is only necessary as we're using SOAP v1.2.  
  If you forget this line and you've specified SOAP v1.2 in your WSDL you'll 
  receive a runtime exception about the wrong content-type header as follows:

  SEVERE: Unsupported Content-Type: application/soap+xml; 
  charset=UTF-8 Supported ones are: [text/xml]
  com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type:  
  application/soap+xml; charset=UTF-8 Supported ones are: [text/xml]

也许您正在尝试使用错误的 SOAP 版本。

Glassfish 还有一个 SOAP 1.2 页面来提供帮助。

Extrated from someone else

  The @BindingType annotation is only necessary as we're using SOAP v1.2.  
  If you forget this line and you've specified SOAP v1.2 in your WSDL you'll 
  receive a runtime exception about the wrong content-type header as follows:

  SEVERE: Unsupported Content-Type: application/soap+xml; 
  charset=UTF-8 Supported ones are: [text/xml]
  com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type:  
  application/soap+xml; charset=UTF-8 Supported ones are: [text/xml]

Maybe you are trying to use the wrong SOAP version.

Glassfish also has a SOAP 1.2 page to help.

梨涡 2024-12-03 19:25:12

您可以从 sun- jaxws.xml

You could remove binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/" from endpoint definition in the sun-jaxws.xml.

通知家属抬走 2024-12-03 19:25:12

抱歉重新提出这么老的问题。
我只是想添加一些关于为什么 SOAP v1.1 服务器不可能(至少在理论上)接受除 text/xml 之外的其他 MIME 的信息。

W3C 上有关 SOAP v1.1 的文档 (§6) 指出

在 HTTP 消息中包含 SOAP 实体主体时,HTTP 应用程序必须根据 RFC 2376 使用媒体类型“text/xml”。

如果我们查看最新的 SOAP v1.2 (§1.3) 文档 我们发现的是:

媒体类型“application/soap+xml”应该用于 SOAP 消息信息集的 XML 1.0 序列化

我认为一个不错的尝试可能是添加实现 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

HTTP applications MUST use the media type "text/xml" according to RFC 2376 when including SOAP entity bodies in HTTP messages.

While if we look at the most recent documentation of SOAP v1.2 (§1.3) what we find is:

The media type "application/soap+xml" SHOULD be used for XML 1.0 serializations of the SOAP message infoset

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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文