Asked by:
WCF host and Android Client, Ksoap2 http request failed, http status : 404

Question
-
Hi Im had check & recheck my KSoap2 param : Namespace, Method, SoapAction, and URL everythings looks ok but I always got error 404
The WFC service I create based on microsoft examples: https://docs.microsoft.com/en-us/dotnet/framework/wcf/getting-started-tutorial
Using the examples C# Client was success to call the WFC services, opening from browser to get xml info was success, also using WFC Test Client also success.
I already open tcp in/out port 8000 for this. Following some hints on the web Im also had change WSHttpBinding into BasicHttpBinding in my host. But when I tried to call from Android Studio 3.0 using KSoap2 ver3.6.2 its always got 404
below is the xml data I copied from browse :
This XML file does not appear to have any style information associated with it. The document tree is shown below. <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss- wssecurity-utility-1.0.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" name="CalculatorService" targetNamespace="http://tempuri.org/"> <wsdl:types> <xsd:schema targetNamespace="http://tempuri.org/Imports"> <xsd:import schemaLocation="http://localhost:8000/WCFTRIAL?xsd=xsd0" namespace="http://tempuri.org/"/> <xsd:import schemaLocation="http://localhost:8000/WCFTRIAL?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/> </xsd:schema> </wsdl:types> <wsdl:message name="ICalculator_Add_InputMessage"> <wsdl:part name="parameters" element="tns:Add"/> </wsdl:message> <wsdl:message name="ICalculator_Add_OutputMessage"> <wsdl:part name="parameters" element="tns:AddResponse"/> </wsdl:message> <wsdl:message name="ICalculator_Subtract_InputMessage"> <wsdl:part name="parameters" element="tns:Subtract"/> </wsdl:message> <wsdl:message name="ICalculator_Subtract_OutputMessage"> <wsdl:part name="parameters" element="tns:SubtractResponse"/> </wsdl:message> <wsdl:message name="ICalculator_Multiply_InputMessage"> <wsdl:part name="parameters" element="tns:Multiply"/> </wsdl:message> <wsdl:message name="ICalculator_Multiply_OutputMessage"> <wsdl:part name="parameters" element="tns:MultiplyResponse"/> </wsdl:message> <wsdl:message name="ICalculator_Divide_InputMessage"> <wsdl:part name="parameters" element="tns:Divide"/> </wsdl:message> <wsdl:message name="ICalculator_Divide_OutputMessage"> <wsdl:part name="parameters" element="tns:DivideResponse"/> </wsdl:message> <wsdl:message name="ICalculator_GetJunkData_InputMessage"> <wsdl:part name="parameters" element="tns:GetJunkData"/> </wsdl:message> <wsdl:message name="ICalculator_GetJunkData_OutputMessage"> <wsdl:part name="parameters" element="tns:GetJunkDataResponse"/> </wsdl:message> <wsdl:portType name="ICalculator"> <wsdl:operation name="Add"> <wsdl:input wsaw:Action="http://tempuri.org/ICalculator/Add" message="tns:ICalculator_Add_InputMessage"/> <wsdl:output wsaw:Action="http://tempuri.org/ICalculator/AddResponse" message="tns:ICalculator_Add_OutputMessage"/> </wsdl:operation> <wsdl:operation name="Subtract"> <wsdl:input wsaw:Action="http://tempuri.org/ICalculator/Subtract" message="tns:ICalculator_Subtract_InputMessage"/> <wsdl:output wsaw:Action="http://tempuri.org/ICalculator/SubtractResponse" message="tns:ICalculator_Subtract_OutputMessage"/> </wsdl:operation> <wsdl:operation name="Multiply"> <wsdl:input wsaw:Action="http://tempuri.org/ICalculator/Multiply" message="tns:ICalculator_Multiply_InputMessage"/> <wsdl:output wsaw:Action="http://tempuri.org/ICalculator/MultiplyResponse" message="tns:ICalculator_Multiply_OutputMessage"/> </wsdl:operation> <wsdl:operation name="Divide"> <wsdl:input wsaw:Action="http://tempuri.org/ICalculator/Divide" message="tns:ICalculator_Divide_InputMessage"/> <wsdl:output wsaw:Action="http://tempuri.org/ICalculator/DivideResponse" message="tns:ICalculator_Divide_OutputMessage"/> </wsdl:operation> <wsdl:operation name="GetJunkData"> <wsdl:input wsaw:Action="http://tempuri.org/ICalculator/GetJunkData" message="tns:ICalculator_GetJunkData_InputMessage"/> <wsdl:output wsaw:Action="http://tempuri.org/ICalculator/GetJunkDataResponse" message="tns:ICalculator_GetJunkData_OutputMessage"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="BasicHttpBinding_ICalculator" type="tns:ICalculator"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="Add"> <soap:operation soapAction="http://tempuri.org/ICalculator/Add" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="Subtract"> <soap:operation soapAction="http://tempuri.org/ICalculator/Subtract" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="Multiply"> <soap:operation soapAction="http://tempuri.org/ICalculator/Multiply" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="Divide"> <soap:operation soapAction="http://tempuri.org/ICalculator/Divide" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> <wsdl:operation name="GetJunkData"> <soap:operation soapAction="http://tempuri.org/ICalculator/GetJunkData" style="document"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="CalculatorService"> <wsdl:port name="BasicHttpBinding_ICalculator" binding="tns:BasicHttpBinding_ICalculator"> <soap:address location="http://localhost:8000/WCFTRIAL/CalculatorService"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
and this is my code in Android Studio:
private class Soapcall extends AsyncTask<String,Object,String>{ public static final String NAMESPACE ="http://tempuri.org/"; public static final String METHOD_NAME ="GetJunkData"; public static final String SOAPACTION = "http://tempuri.org/ICalculator/GetJunkData"; public static final String URI = "http://192.168.1.201:8000/WCFTRIAL?wsdl"; public static final int Timeout=3000; String response; @Override protected String doInBackground(String... strings) { SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet=true; envelope.setOutputSoapObject(request); HttpTransportSE transport = new HttpTransportSE(URI,Timeout); try{ transport.call(SOAPACTION,envelope); //<--ERROR OCCUR HERE response = (String)envelope.getResponse(); }catch (Exception e){ e.printStackTrace(); Log.e("Error",e.getMessage().toString()); } return response; }
To summary my
NAMESPACE ="http://tempuri.org/"; METHOD_NAME ="GetJunkData"; SOAPACTION = "http://tempuri.org/ICalculator/GetJunkData"; URL ="http://192.168.1.201:8000/WCFTRIAL?wsdl";
Im pretty sure this is correct based on the WSDL, please en-light me how Im to correct this 404 error.
Hi Im had check & recheck my KSoap2 param : Namespace, Method, SoapAction, and URL everythings looks ok but I always got error 404
The WFC service I create based on microsoft examples: https://docs.microsoft.com/en-us/dotnet/framework/wcf/getting-started-tutorial
Using the examples C# Client was success to call the WFC services, opening from browser to get xml info was success, also using WFC Test Client also success.
I already open tcp in/out port 8000 for this. Following some hints on the web Im also had change WSHttpBinding into BasicHttpBinding in my host. But when I tried to call from Android Studio 3.0 using KSoap2 ver3.6.2 its always got 404
below is the xml data I copied from browse :
Hi Im had check & recheck my KSoap2 param : Namespace, Method, SoapAction, and URL everythings looks ok but I always got error 404
The WFC service I create based on microsoft examples: https://docs.microsoft.com/en-us/dotnet/framework/wcf/getting-started-tutorial
Using the examples C# Client was success to call the WFC services, opening from browser to get xml info was success, also using WFC Test Client also success.
I already open tcp in/out port 8000 for this. Following some hints on the web Im also had change WSHttpBinding into BasicHttpBinding in my host. But when I tried to call from Android Studio 3.0 using KSoap2 ver3.6.2 its always got 404
below is the xml data I copied from browse :
Friday, November 3, 2017 4:29 PM
All replies
-
I suggest that you use Fiddler and look at the raw HTML traffic when you get the 404.
Friday, November 3, 2017 5:32 PM -
thank your for your advice, i will tried it.
Ok I had download it and tried it but it seem Flidder can not caputre the http transport from Android Studio using Virtual Phone to send Http.
Ill attach both the breakpoint tin Android Studio when it got error 404 but Fidder did not capture that activity
Maybe I got someting need to setup in Fidder I already add the script as faq said:
well any help ?
- Edited by ngherry Saturday, November 4, 2017 5:41 AM
Saturday, November 4, 2017 4:18 AM -
Saturday, November 4, 2017 5:53 PM
-
Hi ngherry,
Are the Android Studio and C# client in the same computer? If not, I suggest you check whether the C# client could work with the URL http://192.168.1.201:8000/WCFTRIAL?wsdl in Android Studio computer?
Your service address is a little strange, did you create WCF Service library and then self-host it like hosting in WinForm? If it is, I suggest you try this address http://192.168.1.201:8000/WCFTRIAL.
In addition, I suggest you check below link.
#getting java.io.IOException: HTTP request failed, HTTP status: 404 in ksoap2 while passing xml data to soap1.2 android
Best Regards,
Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Monday, November 6, 2017 1:46 AM -
ok thank you for ypur replay all, I had found the cause
1. The correct endpoint should : http://192.168.1.201:8000/WCFTRIAL/CalculatorService
2. Its still did not works, because when I create the self-host Im in Japanese locale, and when I open then Client project Im in US-English locale I copied & paste the link from Japanse locale into US-English locale, I notice this when I type directly into browser it work, but Copy& paste did not work. Something like "what you see is not what you get"
Cost me 2 days of works.....hopes this will help others in future referance
Thank again
- Proposed as answer by Edward8520Microsoft contingent staff Tuesday, November 7, 2017 2:36 AM
Monday, November 6, 2017 1:33 PM -
Hi ngherry,
Thanks for sharing your solution, I would suggest you mark the helpful reply as answer, and then others who run into the same issue would find the solution easily.
Best Regards,
Edward
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Tuesday, November 7, 2017 2:35 AM