webService 服务器未能识别 HTTP 头 SOAPAction 的值 java编程

歡歖 2019-03-04 09:23:19
@Test
public void getRegionDataset_soap11() throws MalformedURLException, SOAPException, TransformerException {

String wsdlDocumentLocation = "http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl";
String nameSpace = "http://WebXml.com.cn/";
String serviceName = "WeatherWS";
String portName = "WeatherWSSoap";

javax.xml.ws.Service service = javax.xml.ws.Service.create(new URL(wsdlDocumentLocation), new QName(nameSpace, serviceName));
Dispatch<SOAPMessage> dispatch = service.createDispatch(new QName(nameSpace, portName),
SOAPMessage.class, javax.xml.ws.Service.Mode.MESSAGE);


SOAPMessage soapMessage = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
envelope.addNamespaceDeclaration("method", nameSpace);

SOAPHeader soapHeader = envelope.getHeader();
soapHeader.addAttribute(new QName(nameSpace, "SOAPAction", "method"), "http://WebXml.com.cn/getRegionDataset");

SOAPBody soapBody = envelope.getBody();
SOAPElement operation = soapBody.addBodyElement(new QName("http://WebXml.com.cn/", "getRegionDataset"));


MimeHeaders mimeHeaders = soapMessage.getMimeHeaders();
mimeHeaders.setHeader("SOAPAction","http://WebXml.com.cn/getRegionDataset");

//请求webService
SOAPMessage response = dispatch.invoke(soapMessage);

// 输出响应结果
System.out.println("---------------------- response document ----------------------");
Document doc = response.getSOAPPart().getEnvelope().getBody().extractContentAsDocument();
}




com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: 服务器未能识别 HTTP 头 SOAPAction 的值: 。 Please see the server log to find more detail regarding exact cause of the failure.


发这个问答不知道为什么封号了就
...全文
538 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
(☆随缘☆) 2019-03-04
  • 打赏
  • 举报
回复
因为触及问答系统规则被锁定了,已解锁,建议截图发帖避免再次被锁。

605

社区成员

发帖
与我相关
我的任务
社区描述
客服专区
其他 技术论坛(原bbs)
社区管理员
  • 客服专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧