org.apache.cxf.transport.http.HTTPException:HTTP 响应“415:不支持的媒体类型”
org.apache.cxf.transport.http.HTTPException: HTTP response '415: Unsupported Media Type'
我正在尝试使用 apache CXF 客户端调用 o SOAP Web 服务,但出现上述错误。我尝试使用 SOAP12HTTP_BINDING 修复此问题,但随后发生以下错误:
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: 试图在不允许的地方插入节点
出站消息如下:
Address: myHostName
HttpMethod: POST
Content-Type: text/xml
ExchangeId: myExchangeId
ServiceName: myServiceName
PortName: myPortName
PortTypeName: DummyImpl
Headers: {SOAPAction="mySoapAction",
Accept=*/*, Host=myHost,
Accept-Encoding=gzip,deflate,
Content-Type=application/soap+xml;
charset=UTF-8;action="}
Payload: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="myNamespace">
<soapenv:Body>
<a:operatioName>
...
</a:operatioName>
</soapenv:Body>
</soapenv:Envelope>
原来问题出在 Content-Type header,我将其更改为 text/xml;charset=UTF-8 并且有效。
我正在尝试使用 apache CXF 客户端调用 o SOAP Web 服务,但出现上述错误。我尝试使用 SOAP12HTTP_BINDING 修复此问题,但随后发生以下错误:
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: 试图在不允许的地方插入节点
出站消息如下:
Address: myHostName
HttpMethod: POST
Content-Type: text/xml
ExchangeId: myExchangeId
ServiceName: myServiceName
PortName: myPortName
PortTypeName: DummyImpl
Headers: {SOAPAction="mySoapAction",
Accept=*/*, Host=myHost,
Accept-Encoding=gzip,deflate,
Content-Type=application/soap+xml;
charset=UTF-8;action="}
Payload: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="myNamespace">
<soapenv:Body>
<a:operatioName>
...
</a:operatioName>
</soapenv:Body>
</soapenv:Envelope>
原来问题出在 Content-Type header,我将其更改为 text/xml;charset=UTF-8 并且有效。