获得' InternalServiceFault'尝试调用svc webservice时的异常(托管在IIS服务器中)

时间:2015-05-12 06:16:42

标签: android .net

获取' InternalServiceFault'尝试在Android中使用kso​​ap2调用svc webservice(在IIS服务器中托管)时出现异常。

发生异常:

  

W / System.err:SoapFault - faultcode:' a:InternalServiceFault'   faultstring:' OperationFormatter遇到一个无效的Message主体。   预计会找到节点类型'元素'名字' GetUnits'和   命名空间' http://tempuri.org/'。找到节点类型'元素'有名字   ' GetUnits'和命名空间' http://tempuri.org/IRestaurant/''   faultactor:' null'详情:org.kxml2.kdom.Node@40c821a8 05-11   22:26:30.068 913-921 / com.org.ansal.placemaorder W / System.err:at   org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:137)

请求:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:itemId>1</tem:itemId>
   </soapenv:Body>
</soapenv:Envelope>

调用代码:

  new FetchData(LoginActivity.this).execute("http://tempuri.org/IRestaurant/","GetUnits","http://10.0.0.2/RestaurantServices/RegistrationServices.svc");

服务电话

@Override
protected String doInBackground(String... params) {
    String result="";
    String _NAMESPACE   = params[0];
    String _METHOD_NAME = params[1];
    String URL     = params[2];
    String _SOAP_ACTION = _NAMESPACE + _METHOD_NAME;
    SoapObject request = new SoapObject(_NAMESPACE, _METHOD_NAME);
    request.addProperty("itemId",1);
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;

    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    try {
        androidHttpTransport.debug = true;
        androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding= \"UTF-8\"?>");
        androidHttpTransport.call(_SOAP_ACTION, envelope);
        SoapObject   resultsRequestSOAP = (SoapObject) envelope.getResponse();
        result  = resultsRequestSOAP.toString();
        System.out.println("****** RESULT: " + resultsRequestSOAP.toString());
    } catch (Exception e) {
        System.out.println("******* THERE WAS AN ERROR ACCESSING THE WEB SERVICE");
        e.printStackTrace();
    }

    return result;
    }

1 个答案:

答案 0 :(得分:1)

  

预计会找到名为“GetUnits”和名称空间“http://tempuri.org/”的节点类型“Element”。找到名为“GetUnits”的节点类型“Element”和名称空间“http://tempuri.org/IRestaurant/

更改您的obj.size

Namespace

为:

"tempuri.org/IRestaurant/";