Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ksoap2在Android上使用WCF服务-内部服务器错误_Android_.net_Wcf_Soap_Ksoap2 - Fatal编程技术网

使用ksoap2在Android上使用WCF服务-内部服务器错误

使用ksoap2在Android上使用WCF服务-内部服务器错误,android,.net,wcf,soap,ksoap2,Android,.net,Wcf,Soap,Ksoap2,我正在为WCF服务开发一个Android客户端。有一个windows应用程序与该服务配合使用,没有任何问题。然而,当我尝试在Android上使用该服务时,使用kSoap2-我得到了500个内部服务器错误。很明显,我做错了什么,但不知道是什么 以下是我的Java代码: // SOAP consts private static final String NAMESPACE = "http://tempuri.org/"; private static final String SERVICE_NA

我正在为WCF服务开发一个Android客户端。有一个windows应用程序与该服务配合使用,没有任何问题。然而,当我尝试在Android上使用该服务时,使用kSoap2-我得到了500个内部服务器错误。很明显,我做错了什么,但不知道是什么

以下是我的Java代码:

// SOAP consts
private static final String NAMESPACE = "http://tempuri.org/";
private static final String SERVICE_NAME = "/SignService";
private static final String SOAP_ACTION = "http://tempuri.org/ISignService/";
...
String url;
String method_name = "GetExistedSignData";

url = mServerAddress + SERVICE_NAME;

/* the connect logic goes here */
try {
    SoapObject request = new SoapObject(NAMESPACE, method_name);

    request.addProperty("displayId", "HWI_00:1E:8C:87:7F:8D");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);

    envelope.dotNet = true;
    //envelope.implicitTypes = true;
    envelope.setAddAdornments(false);
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
    androidHttpTransport.call(method_name, envelope);
    sb.append(envelope.toString() + "\n");
    SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

    //to get the data
    String resultData = result.toString();
    sb.append(resultData + "\n");
} catch (IOException e) {
    sb.append("IO Problem:\n" + e.getMessage() + "\n");
} catch (XmlPullParserException e) {
    sb.append("Parser Problem:\n" + e.getMessage() + "\n");
}
catch (Exception e) {
    sb.append("Error:\n" + e.getMessage() + "\n");
}
以下是成功调用方法的windows客户端的HTTP转储:

POST /SignService HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
Host: ariadnetest.ariadne.vn
Content-Length: 995
Connection: Keep-Alive

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:r="http://schemas.xmlsoap.org/ws/2005/02/rm" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
    <r:Sequence s:mustUnderstand="1">
    <r:Identifier>urn:uuid:b6073cc9-d142-4045-90cb-1ae8d839d400</r:Identifier>
    <r:MessageNumber>1</r:MessageNumber>
    </r:Sequence>
    <a:Action s:mustUnderstand="1">http://tempuri.org/ISignService/GetExistedSignData</a:Action>
    <a:MessageID>urn:uuid:ad89a2da-6205-460b-b50c-9b354d83594d</a:MessageID>
    <ActivityId xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics" CorrelationId="9c91571d-e363-45da-ab5b-a83d48f3ec82">468b8556-f549-4d1f-969a-591aae05d4af</ActivityId>
    <a:ReplyTo>
    <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <a:To s:mustUnderstand="1">http://ariadnetest.ariadne.vn/SignService</a:To>
</s:Header>
<s:Body>
    <GetExistedSignData xmlns="http://tempuri.org/">
    <displayId>HWI_00:1E:8C:87:7F:8D</displayId>
    </GetExistedSignData>
</s:Body>
</s:Envelope>
错误描述中最有用的部分是:

Error Code 64: Host not available
Background: The connection to the  Web server was lost.

我对WCF和.NET不是很熟悉,所以对于可能出现的错误我没有选择余地。我没有开发我需要在Android中使用的WCF服务。

我认为这句话是错误的:

androidHttpTransport.call(method_name, envelope);

第一个参数应该是:NAMESPACE+METHOD\u NAME

如果您有选择,最好不要在Android上使用SOAP。SOAP要比REST复杂得多,需要一个复杂的框架,而Android至少目前无法使用它。

没有任何区别。根据kSoap2文档,第一个参数用于设置“soapAction”头字段,该字段在SOAP 1.2中未使用。其他选项是什么?
Error Code 64: Host not available
Background: The connection to the  Web server was lost.
androidHttpTransport.call(method_name, envelope);