Java响应的麻烦

时间:2011-07-29 04:55:20

标签: java soap jax-ws

我正在从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 ..有没有办法让我们解析响应?

3 个答案:

答案 0 :(得分:3)

如果您使用maven作为构建工具,请务必检查您的maven目标是否已将XSoap1.2作为协议..我们有一个类似的问题,我们几周都无法解决这个问题..

希望这可以帮助你...

答案 1 :(得分:2)

摘自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]

也许您正在尝试使用错误的SOAP版本。 Glassfish还有一个SOAP 1.2 page来帮忙。

答案 2 :(得分:1)

您可以从binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"中的端点定义中删除sun-jaxws.xml