0

我一直在尝试使用 .NET 网络服务

private static final String SOAP_ACTION = "http://tempuri.org/ICustomers/getAllProductsDT";
private static final String METHOD_NAME = "getAllProductsDT";
private static final String NAMESPACE = "http://tempuri.org/";
private static final String URL = "http://10.121.11.53/Customers/Customers.svc";




SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransportSE = new HttpTransportSE(URL);
androidHttpTransportSE.debug=true;
androidHttpTransportSE.call(SOAP_ACTION, soapEnvelope);
String str= soapEnvelope.getResponse().toString();

我的第一个日志没有出现在 logcat 中,第二个日志我发现了以下异常:

org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@1:6 in java.io.InputStreamReader@43e56bb0) 

05-14 16:08:28.573: W/System.err(3532): org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <HTML>@1:6 in java.io.InputStreamReader@43e56bb0) 
4

1 回答 1

1

它不是 android 或 WebService 的问题。

APPCODE 中可能有一个 app_html.offline 不允许它在线运行。

转到 C# 中的解决方案资源管理器。

右键单击并将其从项目中排除。:D

您应该具有以下格式才能使用 ksoap 在 android 中使用 .net Web 服务。

   private static final String URL = "http://....asmx"; // Make sure that the url is end with .asmx
   private static final String NAMESPACE = "http://domain.com"; // It may contain "/" at the of name space. Because it's your name space.
   private static final String METHOD_NAME = "UserLogin"; // Method Name
   private static final String SOAP_ACTION = "http://domain.com/UserLogin"; // Domain and method name.

只需要遵循上述结构即可。

于 2013-05-14T12:41:38.347 回答