【问题标题】:java trouble with SOAP responseSOAP响应的java问题
【发布时间】:2011-07-29 04:55:20
【问题描述】:

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

【问题讨论】:

    标签: java soap jax-ws


    【解决方案1】:

    如果您使用 maven 作为构建工具,请务必检查您的 maven 目标是否将 XSoap1.2 作为协议。我们遇到了类似的问题,我们数周都无法解决。

    希望对你有帮助...

    【讨论】:

      【解决方案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 来提供帮助。

      【讨论】:

      • 我们使用的是 SOAP v1.1.. 但是(很明显)客户端使用的是 SOAP 1.2.. 有没有办法让我们解析响应?
      【解决方案3】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-11-27
        • 2014-06-20
        • 2011-03-25
        相关资源
        最近更新 更多