使用java standalone的没有客户端代码的WebService调用

时间:2015-03-02 19:46:14

标签: webservices-client

我面临同样的问题。这是我的踪迹。没有Web服务客户端代码,我试图使用java形成SOAP请求xml并将请求发送到Web服务端点。

SEVERE: SAAJ0008: Bad Response; Cannot process the message because the content type 'text/xml' was not the expected type 'application/soap+xml; charset=utf-8'.
Error occurred while sending SOAP Request to Server
com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: java.security.PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (415Cannot process the message because the content type 'text/xml' was not the expected type 'application/soap+xml; charset=utf-8'.
      at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
      at com.optus.idm.util.BaseBean.getPinStatus(BaseBean.java:220)
      at com.optus.idm.util.BaseBean.main(BaseBean.java:247)
Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (415Cannot process the message because the content type 'text/xml' was not the expected type 'application/soap+xml; charset=utf-8'.
      at java.security.AccessController.doPrivileged(Native Method)
      ... 3 more
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (415Cannot process the message because the content type 'text/xml' was not the expected type 'application/soap+xml; charset=utf-8'.
      at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
      at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection$PriviledgedPost.run(Unknown Source)
      ... 4 more

当我从java复制生成的XML并将其与SOAP UI一起使用时,它完全没问题但是当我使用java soap连接器发送时,它抛出上面的错误。请帮帮我

1 个答案:

答案 0 :(得分:0)

尝试使用Java的WSDL生成器之一。它将使您的编码更容易。 例如:http://www.eclipse.org/webtools/community/education/web/t320/Generating_a_client_from_WSDL.pdf 要么 http://netbeans.dzone.com/news/5-techniques-create-web-servic

如果您真的想手动完成,则需要查找SOAP数据包的标准要求。 XML必须符合规范。