我正在尝试从 ASMX Web 服务获取数据。我已经使用了这里的代码并使用了它的 ConvertWaight Web 服务,但它不起作用。
它向我显示错误java.net.SocketTimeoutException: Transport endpoint is not connected
。我已经添加了网络权限,但仍然出现此错误。
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
请帮助我,任何示例代码都会非常有帮助。
我的网络服务NSDictionary
在 iOS 中接受。像这样...
{
memberDetails = {
DeviceName = "iPhone Simulator";
DeviceToken = 951fc5a77184ds1a17474256759a34e03d31b708a0358v742df38bb3cc845ds4;
EmailAddress = "user@org.com";
IsRemember = True;
Password = "123456789";
};
}
所以在android中我试图将HasMap传递给webservice
如果有帮助,这是我的网络服务
POST /service/xxx.asmx HTTP/1.1
Host: www.xxx.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/SelectByEmailAndPassword"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<SelectByEmailAndPassword xmlns="http://tempuri.org/">
<memberDetails>
<EmailAddress>string</EmailAddress>
<Password>string</Password>
<DeviceToken>string</DeviceToken>
<DeviceName>string</DeviceName>
<IsRemember>boolean</IsRemember>
</memberDetails>
</SelectByEmailAndPassword>
</soap:Body>
</soap:Envelope>
这是我调用网络服务的代码
public String Call(String deviceName, String deviceToken, String emailAddress, String isRemember, String password)
{
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
PropertyInfo pi=new PropertyInfo();
//Create a HashMap
Map <String,String> memberDetails = new HashMap<String,String>();
//Put data into the HashMap
memberDetails.put("DeviceName","android Simulator");
memberDetails.put("DeviceToken","951fc5a77184ds1a17474256759a34e03d31b708a0358v742df38bb3cc845ds4");
memberDetails.put("EmailAddress","user@org.com");
memberDetails.put("IsRemember","True");
memberDetails.put("Password","123456789");
pi.setName("memberDetails");
pi.setValue(memberDetails.toString());
pi.setType(String.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
Object response=null;
try
{
httpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
}
catch (Exception exception)
{
response=exception.toString();
}
return response.toString();
}
}