【问题标题】:soap 1.2 android Please supply a valid soap actionsoap 1.2 android 请提供一个有效的肥皂动作
【发布时间】:2012-06-06 08:04:46
【问题描述】:

我的 .net 网络服务显然正在运行 soap 1.2(通过检查 .wsdl),我一直在尝试访问 helloworld 网络服务进行测试,但我遇到了错误。 顺便说一句,我试图通过模拟器来做到这一点。

所以当我使用soap 1.2 版本时,我收到错误消息“无法在没有有效操作参数的情况下处理请求。请提供有效的soap” 我想知道我缺少什么以及我应该怎么做。

谢谢!

我已经做过的事情:

  • 添加安卓使用网络权限
  • 从 Soap 版本 1.1 和 1.2 更改
  • 从 SoapObject 更改为 Object(对于 soap 1.1 和 1.2)
  • 模拟器使用 10.0.2.2
  • 检查地址和方法名称的拼写错误

我的代码:

 private static final String NAMESPACE = "http://localhost/WebService/";
 private static final String URL = "http://10.0.2.2:1672/Eventurous/WsEventurousMobile.asmx";
 private static final String HelloWorld_SOAP_ACTION = "http://localhost/WebService/HelloWorld";
 private static final String METHOD_NAME1 = "HelloWorld";



...
...

public static String GetHelloWorld() {

  SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
  SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
     SoapEnvelope.VER12);
  envelope.dotNet = true;
  envelope.setOutputSoapObject(request);
  HttpTransportSE androidHttpTransport = new HttpTransportSE(URL,60000);

  try {
   androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    androidHttpTransport.call(HelloWorld_SOAP_ACTION, envelope);

   SoapObject response = (SoapObject)envelope.getResponse(); 
   String result = response.getProperty(0).toString(); 

   return result;
   } catch (Exception e) {
   return e.toString();
  }

 }

Soap 1.2 版出错

Code: soap:Sender, Reason: System.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action.

 at System.Web.Services.Protocols.Soap12ServerProtocolHelper.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

Soap 1.1 版出错

SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://localhost/WebService/HelloWorld.

 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)' faultactor: 'null' detail: org.kxml2.kdom.Node@413c9098

【问题讨论】:

    标签: android web-services soap ksoap2


    【解决方案1】:

    使用 SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

    而不是

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
         SoapEnvelope.VER12);
    

    并删除此行androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");

    而不是SoapObject response = (SoapObject)envelope.getResponse();

    使用SoapObject response = (SoapObject)envelope.bodyIn;

    它会帮助你。如果仍然出错,请写信给我。

    【讨论】:

      猜你喜欢
      • 2022-08-17
      • 2018-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多