Search code examples
androidsoaphttp-status-code-404android-ksoap2

SOAP from Android giving 404


So I'm getting http error 404 indicating I'm trying to access something which isn't there. I can't seem to figure out whats missing or that I've misunderstood.

  • Namespace: http://tempuri.org/
  • URL: http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc?wsdl
  • Action: SetPulseOxi
  • Soap_action: http://tempuri.org/IPulseOxi/SetPulseOxi

The soap service works from SOAPUI but not from my ksoap2 Android implementation. I've also tryed sending raw SOAP that I know worked through SOAPUI.

Example request from Android ksoap:

<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
    <v:Header />
    <v:Body>
        <SetPulseOxi xmlns="http://tempuri.org/">
            <DeviceID>test1</DeviceID>
            <UnitID>test2</UnitID>
        </SetPulseOxi>
    </v:Body>
</v:Envelope>

This is the full wsdl:

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" name="PulseOxiSvc" targetNamespace="http://tempuri.org/">
    <wsp:Policy wsu:Id="IPulseOxi_policy">
        <wsp:ExactlyOne>
            <wsp:All>
                <http:BasicAuthentication xmlns:http="http://schemas.microsoft.com/ws/06/2004/policy/http"/>
            </wsp:All>
        </wsp:ExactlyOne>
    </wsp:Policy>
    <wsdl:types>
        <xsd:schema targetNamespace="http://tempuri.org/Imports">
            <xsd:import schemaLocation="http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
            <xsd:import schemaLocation="http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
            <xsd:import schemaLocation="http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/WcfHomeCare"/>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name="IPulseOxi_GetPulseOxiById_InputMessage">
        <wsdl:part name="parameters" element="tns:GetPulseOxiById"/>
    </wsdl:message>
    <wsdl:message name="IPulseOxi_GetPulseOxiById_OutputMessage">
        <wsdl:part name="parameters" element="tns:GetPulseOxiByIdResponse"/>
    </wsdl:message>
    <wsdl:message name="IPulseOxi_GetAllPulseOxi_InputMessage">
        <wsdl:part name="parameters" element="tns:GetAllPulseOxi"/>
    </wsdl:message>
    <wsdl:message name="IPulseOxi_GetAllPulseOxi_OutputMessage">
        <wsdl:part name="parameters" element="tns:GetAllPulseOxiResponse"/>
    </wsdl:message>
    <wsdl:message name="IPulseOxi_SetPulseOxi_InputMessage">
        <wsdl:part name="parameters" element="tns:SetPulseOxi"/>
    </wsdl:message>
    <wsdl:message name="IPulseOxi_SetPulseOxi_OutputMessage">
        <wsdl:part name="parameters" element="tns:SetPulseOxiResponse"/>
    </wsdl:message>
    <wsdl:portType name="IPulseOxi">
        <wsdl:operation name="GetPulseOxiById">
            <wsdl:input wsaw:Action="http://tempuri.org/IPulseOxi/GetPulseOxiById" message="tns:IPulseOxi_GetPulseOxiById_InputMessage"/>
            <wsdl:output wsaw:Action="http://tempuri.org/IPulseOxi/GetPulseOxiByIdResponse" message="tns:IPulseOxi_GetPulseOxiById_OutputMessage"/>
        </wsdl:operation>
        <wsdl:operation name="GetAllPulseOxi">
            <wsdl:input wsaw:Action="http://tempuri.org/IPulseOxi/GetAllPulseOxi" message="tns:IPulseOxi_GetAllPulseOxi_InputMessage"/>
            <wsdl:output wsaw:Action="http://tempuri.org/IPulseOxi/GetAllPulseOxiResponse" message="tns:IPulseOxi_GetAllPulseOxi_OutputMessage"/>
        </wsdl:operation>
        <wsdl:operation name="SetPulseOxi">
            <wsdl:input wsaw:Action="http://tempuri.org/IPulseOxi/SetPulseOxi" message="tns:IPulseOxi_SetPulseOxi_InputMessage"/>
            <wsdl:output wsaw:Action="http://tempuri.org/IPulseOxi/SetPulseOxiResponse" message="tns:IPulseOxi_SetPulseOxi_OutputMessage"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="IPulseOxi" type="tns:IPulseOxi">
        <wsp:PolicyReference URI="#IPulseOxi_policy"/>
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="GetPulseOxiById">
            <soap:operation soapAction="http://tempuri.org/IPulseOxi/GetPulseOxiById" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="GetAllPulseOxi">
            <soap:operation soapAction="http://tempuri.org/IPulseOxi/GetAllPulseOxi" style="document"/>
            <wsdl:input>
                <soap:body use="literal"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use="literal"/>
            </wsdl:output>
        </wsdl:operation>
        <wsdl:operation name="SetPulseOxi">
            <soap:operation soapAction="http://tempuri.org/IPulseOxi/SetPulseOxi" 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="PulseOxiSvc">
        <wsdl:port name="IPulseOxi" binding="tns:IPulseOxi">
            <soap:address location="http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc/WcfHomeCare"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

Solution

  • i am not sure if this is a help or breakthrough ... or just nothing

    if you change the URL to http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc/WcfHomeCare with target http://tempuri.org/IPulseOxi/SetPulseOxi i got a result (Android ksoap2) result is: Object reference not set to an instance of an object.

    if i use action as http://tempuri.org/SetPulseOxi i got a 500 response unfortunately i could not get a correct response, at least the URL thing is 100% a breakthrough.

    here is the code i used:

    final String NAMESPACE = "http://tempuri.org/";
        final String URL = "http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc/WcfHomeCare";
        String methodName = "SetPulseOxi";
        String soapAction = "http://tempuri.org/IPulseOxi/SetPulseOxi";//NAMESPACE + methodName;
        
        SoapObject request = new SoapObject(NAMESPACE, methodName);
        
        PropertyInfo hhh = new PropertyInfo();
        hhh.setName("DeviceID");
        hhh.setValue("testA");
        hhh.setType(String.class);
        request.addProperty(hhh);
        
        PropertyInfo ddd = new PropertyInfo();
        ddd.setName("UnitID");
        ddd.setValue("testB");
        ddd.setType(String.class);
        request.addProperty(ddd);
        
        PropertyInfo asas = new PropertyInfo();
        asas.setName("UserID");
        asas.setValue("1");
        asas.setType(String.class);
        request.addProperty(asas);
        
        PropertyInfo jkjk = new PropertyInfo();
        jkjk.setName("pulse_avg");
        jkjk.setValue("1");
        jkjk.setType(String.class);
        request.addProperty(jkjk);
        
        PropertyInfo location = new PropertyInfo();
        location.setName("pulse_max");
        location.setValue("1");
        location.setType(String.class);
        request.addProperty(location);
        
        PropertyInfo xx = new PropertyInfo();
        xx.setName("pulse_min");
        xx.setValue("1");
        xx.setType(String.class);
        request.addProperty(xx);
        
        PropertyInfo yy = new PropertyInfo();
        yy.setName("spO2_avg");
        yy.setValue("1");
        yy.setType(String.class);
        request.addProperty(yy);
        
        PropertyInfo as = new PropertyInfo();
        as.setName("spO2_max");
        as.setValue("1");
        as.setType(String.class);
        request.addProperty(as);
        
        PropertyInfo ff = new PropertyInfo();
        ff.setName("spO2_min");
        ff.setValue("1");
        ff.setType(String.class);
        request.addProperty(ff);
        
        PropertyInfo tt = new PropertyInfo();
        tt.setName("uid");
        tt.setValue("1");
        tt.setType(String.class);
        request.addProperty(tt);
        
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL, 15000);
        androidHttpTransport.debug=true;
        try {
            androidHttpTransport.call(soapAction, envelope);
            String result = envelope.getResponse().toString() ;
            Log.i("YAZAN", result);
            
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        }
    

    ** plz ignore property stupid names :) **

    More Details: if you open http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc?wsdl go down to end of file, you will see this

    <wsdl:service name="PulseOxiSvc">
    <wsdl:port name="IPulseOxi" binding="tns:IPulseOxi">
    <soap:address location="http://testnet.medisat.dk:81/WcfHomeCare/PulseOxiSvc.svc/WcfHomeCare"/>
    </wsdl:port>
    </wsdl:service>
    

    as you can see location="http://.../WcfHomeCare" i worked with SOAP services before, but location was the same as URL so i am not sure if this is something optional to set a different URL for location or it's based on specific needs.

    from there, i think rest of story is yours :)