I'm trying to connect to web service through android client (emulator) and I know there are quite a few similar questoins, but non of the solutions helped me so far. In particular, I followed first two answers from this question. I double-checked namespace, url, method name and soap_action strings several times, also, I tried assigning different values to envelope.env
(not sure if it's a right way to do it though), but it did't really help.
So what is next that I should do/change? I've been tackling this for two days now and it's getting a bit frustrating. Any help is appreciated
This error:
com.example.webserviceactivity W/System.err﹕ org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://www.w3.org/2003/05/soap}Envelope (position:START_TAG <HTML>@2:7 in java.io.InputStreamReader@b1272710)
This is my class
public class MainActivity extends Activity {
private final String METHOD_NAME = "GetNextRow";
private final String NAMESPACE = "http://tempuri.org/";
private final String SOAP_ACTION = "http://tempuri.org/GetNextRow";
private final String URL = "http://10.0.2.2:63054/BundlesWS.asmx";
private String TAG = "TAG";
private static String newQuantity;
private SoapObject resultRequestSOAP ;
TextView tv;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView) findViewById(R.id.textViewResultQTY);
}
public void btnQTY(View view) {
Toast.makeText(this, "Quantity", Toast.LENGTH_SHORT).show();
AsyncCallWS task = new AsyncCallWS();
task.execute();
}
public void getQuantity() {
resultRequestSOAP = new SoapObject(NAMESPACE, METHOD_NAME);
//Create envelope
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
//Tried defferent values here:
//1. http://www.w3.org/2001/XMLSchema
//2. http://schemas.xmlsoap.org/soap/envelope
//3. http://schemas.xmlsoap.org/wsdl/soap/
//4. http://www.w3.org/2001/XMLSchema
//also I tried totally removing enelope.env..
envelope.env = "http://www.w3.org/2003/05/soap";
envelope.dotNet = true;
envelope.setOutputSoapObject(resultRequestSOAP);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
}
} catch (Exception e) {
e.printStackTrace();
}
try {
SoapObject response = (SoapObject) envelope.getResponse();
newQuantity = response.getProperty(0).toString();
} catch (Exception e) {
e.printStackTrace();
}
}
private class AsyncCallWS extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
Log.i(TAG, "doInBackground");
getQuantity();
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.i(TAG, "onPostExecute");
System.out.print(result);
tv.setText(newQuantity + " units");
}
@Override
protected void onPreExecute() {
Log.i(TAG, "onPreExecute");
tv.setText("Calculating...");
}
@Override
protected void onProgressUpdate(Void... values) {
Log.i(TAG, "onProgressUpdate");
}
}
}
and this is my WSDL
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://tempuri.org/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="GetNextRow">
<s:complexType/>
</s:element>
<s:element name="GetNextRowResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetNextRowResult" type="tns:PickRow"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="PickRow">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ItemNo" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="Quantity" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="Location" ``type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Id" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="Report">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="id" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="quantiy" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ReportResponse">
<s:complexType/>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="GetNextRowSoapIn">
<wsdl:part name="parameters" element="tns:GetNextRow"/>
</wsdl:message>
<wsdl:message name="GetNextRowSoapOut">
<wsdl:part name="parameters" element="tns:GetNextRowResponse"/>
</wsdl:message>
<wsdl:message name="ReportSoapIn">
<wsdl:part name="parameters" element="tns:Report"/>
</wsdl:message>
<wsdl:message name="ReportSoapOut">
<wsdl:part name="parameters" element="tns:ReportResponse"/>
</wsdl:message>
<wsdl:portType name="BundlesWSSoap">
<wsdl:operation name="GetNextRow">
<wsdl:input message="tns:GetNextRowSoapIn"/>
<wsdl:output message="tns:GetNextRowSoapOut"/>
</wsdl:operation>
<wsdl:operation name="Report">
<wsdl:input message="tns:ReportSoapIn"/>
<wsdl:output message="tns:ReportSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BundlesWSSoap" type="tns:BundlesWSSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetNextRow">
<soap:operation soapAction="http://tempuri.org/GetNextRow" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Report">
<soap:operation soapAction="http://tempuri.org/Report" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="BundlesWSSoap12" type="tns:BundlesWSSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetNextRow">
<soap12:operation soapAction="http://tempuri.org/GetNextRow" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Report">
<soap12:operation soapAction="http://tempuri.org/Report" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="BundlesWS">
<wsdl:port name="BundlesWSSoap" binding="tns:BundlesWSSoap">
<soap:address location="http://localhost:63054/BundlesWS.asmx"/>
</wsdl:port>
<wsdl:port name="BundlesWSSoap12" binding="tns:BundlesWSSoap12">
<soap12:address location="http://localhost:63054/BundlesWS.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Not sure if you need a full error log, if you do, I will gladly edit my question. Thank you