我有一个我在IIS中创建的网站和一个在VS.net中创建的Web服务...当我通过浏览器访问网站时,我可以访问该网站并使用所有WebMethods但是当我尝试通过我的Eclipse Android项目访问它,它刚刚赢得了连接...我已经跟随了多个教程并得到了相同的结果。有没有人知道为什么会发生这种情况?
EDIT1
我的response.Dump
是这样的:
401 - Unauthorized: Access is denied due to invalid credentials
虽然捕获的例外是:
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@2:44 in java.io.InputStreamReader@21f07348)
以下是代码:
public void getMessage() {
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://foo/blah/Service1.asmx";
private final String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private final String METHOD_NAME = "HelloWorld";
private String TAG = "SOAP";
private static String message;
String dump;
//Create request
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER10);
//envelope.encodingStyle = SoapSerializationEnvelope.ENC2001;
envelope.dotNet = true;
//Set output SOAP object
envelope.setOutputSoapObject(request);
//Create HTTP call object
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.debug=true;
androidHttpTransport.call(SOAP_ACTION, envelope );
dump = androidHttpTransport.responseDump;
//Get the response
SoapObject response = (SoapObject) envelope.getResponse();
String result = (response.getProperty(0).toString());
//SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
//Assign it to fahren static variable
message = result.toString();
} catch (Exception e) {
//tv.setText(e.getMessage());
e.printStackTrace();
}
}