java SOAP 响应问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6868796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 17:39:19  来源:igfitidea点击:

java trouble with SOAP response

javasoapjax-ws

提问by Anantha Sharma

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,

我正在从 jax-ws java 客户端调用 Web 服务,当我收到响应时,我收到一个异常,说不支持内容类型,

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.

我检查了soap请求中的标题,它表明可接受的内容类型是html/xml、text/jpg等。但不是application/xml+soap。

when testing with SoapUI, things work perfectly.

使用 SoapUI 进行测试时,一切正常。

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?

我们使用的是 SOAP v1.1 .. 但是(显然)客户端使用的是 SOAP 1.2 .. 有没有办法让我们解析响应?

回答by

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..

如果您使用 maven 作为构建工具,请务必检查您的 maven 目标是否将 XSoap1.2 作为协议。

hope this helps you...

希望这对你有帮助...

回答by Nicolas Modrzyk

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.

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

Glassfish also has a SOAP 1.2 pageto help.

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

回答by bambrikii

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

您可以binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"sun-jaxws.xml.