当前位置: 代码迷 >> J2ME >> javax.xml.soap.SOAPException: System.Web.Services.Protocols.
  详细解决方案

javax.xml.soap.SOAPException: System.Web.Services.Protocols.

热度:9698   发布时间:2013-02-25 21:38:23
使用javax.xml.soap.*的问题
使用javax.xml.soap.*去访问一个web service服务出问题。源代码如下
package com;

import javax.xml.messaging.URLEndpoint;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConnection;
import javax.xml.soap.SOAPConnectionFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPMessage;

public class SoapCallService {
private SOAPConnection soapConnection = null;
private boolean initializeSoapConnection()
{
if( soapConnection == null)
{
SOAPConnectionFactory soapConnectionFactory = null;
try
{
soapConnectionFactory = SOAPConnectionFactory.newInstance();
try
{
soapConnectionFactory = SOAPConnectionFactory.newInstance();
}catch(UnsupportedOperationException e){
e.printStackTrace();
}

try
{
soapConnection = soapConnectionFactory.createConnection();
}
catch(SOAPException e)
{
e.printStackTrace();
}
}catch(Exception e){

}
}
return true;
}

public void getResponse()
{
try
{
URLEndpoint urlEndpoint = new URLEndpoint("http://www.webservicex.net/globalweather.asmx?WSDL");
SOAPMessage request = MessageFactory.newInstance().createMessage();
SOAPMessage response = soapConnection.call(request, urlEndpoint);
if(response!=null)
{
SOAPBody responsebody = response.getSOAPBody();
if(responsebody.hasFault())
{
SOAPFault fault = responsebody.getFault();
String faultDescription = fault.getFaultString();
System.out.println("ww:"+faultDescription);
}

}
}catch(Exception e)
{
e.printStackTrace();
}
}

public static void main(String args[]){
SoapCallService soapcall = new SoapCallService();
soapcall.initializeSoapConnection();
soapcall.getResponse();
}
}
结果出问题
- Deploying module: addressing-1.3
javax.xml.soap.SOAPException: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: urn:anonOutInOp.
  at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
  at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
  at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
  at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
at org.apache.axis2.saaj.SOAPConnectionImpl.handleSOAPMessage(SOAPConnectionImpl.java:193)
at org.apache.axis2.saaj.SOAPConnectionImpl.call(SOAPConnectionImpl.java:129)
at com.SoapCallService.getResponse(SoapCallService.java:100)
at com.SoapCallService.main(SoapCallService.java:135)
Caused by: org.apache.axis2.AxisFault: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: urn:anonOutInOp.
  at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
  at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
  at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
  at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:486)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:343)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:389)
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!