我一直在尝试使用.NET webservice
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)
答案 0 :(得分:1)
它不是android或WebService的问题。
APPCODE中可能有一个app_html.offline,它不允许它在线运行。
转到C#中的解决方案资源管理器。
右键单击并从项目中排除它。 :d
和强>
你应该使用以下格式在android中使用ksoap来使用.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.
您需要遵循以上结构。