0

I had connected Android with a webservice using Volley. When connect to url, return me a xml file. The returned xml, contain a function, that i need execute.

Ok, volley don't have a xml parser, I use a 'Simple' xml serializator.

All fine, I'm connectet to webservice, I parsed xml, and have a POJO file for this. Now, how can I do for execute the returned function in xml? I can with volley? I need pass a value into function and receive result.

The xml code:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:microsoft-dynamics-schemas/codeunit/ServicioPrueba" targetNamespace="urn:microsoft-dynamics-schemas/codeunit/ServicioPrueba">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-schemas/codeunit/ServicioPrueba">
<element name="Pruebaaaaaa">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="inputstring" type="string"/>
</sequence>
</complexType>
</element>
<element name="Pruebaaaaaa_Result">
<complexType>
<sequence>
<element minOccurs="1" maxOccurs="1" name="return_value" type="string"/>
</sequence>
</complexType>
</element>
</schema>
</types>
<message name="Pruebaaaaaa">
<part name="parameters" element="tns:Pruebaaaaaa"/>
</message>
<message name="Pruebaaaaaa_Result">
<part name="parameters" element="tns:Pruebaaaaaa_Result"/>
</message>
<portType name="ServicioPrueba_Port">
<operation name="Pruebaaaaaa">
<input name="Pruebaaaaaa" message="tns:Pruebaaaaaa"/>
<output name="Pruebaaaaaa_Result" message="tns:Pruebaaaaaa_Result"/>
</operation>
</portType>
<binding name="ServicioPrueba_Binding" type="tns:ServicioPrueba_Port">
<binding xmlns="http://schemas.xmlsoap.org/wsdl/soap/" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Pruebaaaaaa">
<operation xmlns="http://schemas.xmlsoap.org/wsdl/soap/" soapAction="urn:microsoft-dynamics-schemas/codeunit/ServicioPrueba:Pruebaaaaaa" style="document"/>
<input name="Pruebaaaaaa">
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
</input>
<output name="Pruebaaaaaa_Result">
<body xmlns="http://schemas.xmlsoap.org/wsdl/soap/" use="literal"/>
</output>
</operation>
</binding>
<service name="ServicioPrueba">
<port name="ServicioPrueba_Port" binding="tns:ServicioPrueba_Binding">
<address xmlns="http://schemas.xmlsoap.org/wsdl/soap/" location="https://portatil-gjm.olivia.olivia-sistemas.com:7047/DynamicsNAV100/WS/CRONUS%20Espa%C3%B1a%20S.A./Codeunit/ServicioPrueba"/>
</port>
</service>
</definitions>

The part of the connection in VolleY:

String url = "http://XXXXXXXXX";
SimpleXmlRequest<definitions> simpleRequest = new SimpleXmlRequest<definitions>(Request.Method.GET, url, definitions.class,
new Response.Listener<definitions>()
{
    @Override
    public void onResponse(definitions response) {
        // response Object
        Log.d("WORKS", "onResponse: "+response.getTypes().getSchema());

        }
    },
    new Response.ErrorListener()
    {
        @Override
        public void onErrorResponse(VolleyError error) {
            // error Object
        }
    }
    ){
        @Override
        public Map<String, String> getHeaders() {
        Map<String, String> params = new HashMap<String, String>();
        params.put(
            "Authorization",
            String.format("Basic %s", Base64.encodeToString(
                    String.format("%s:%s", "xxxxx", "xxxx").getBytes(), Base64.NO_WRAP)));
        return params;
}};
queue.add(simpleRequest);
Shreeya Chhatrala
  • 1,441
  • 18
  • 33
Pypypy
  • 31
  • 4
  • It is a bit unclear what you are asking. You are trying to call a SOAP web service? – Henry Jul 28 '17 at 11:34
  • Yes @Henry, but only with one function – Pypypy Jul 28 '17 at 11:36
  • Why are you reading the WSDL at all? If you know the signature of the function to call just call it directly. You will have to assemble a SOAP request for it and then interpret the result in the SOAP response. – Henry Jul 28 '17 at 11:39
  • A lot of thanks @Hernry, I'm a newbie with webservices. Yes I see the signature, but I don't know how meka a soap request on it. – Pypypy Jul 28 '17 at 11:48
  • Here are some links that may help you: https://stackoverflow.com/questions/1484122/android-wsdl-soap-service-client, https://stackoverflow.com/questions/297586/how-to-call-a-soap-web-service-on-android, https://stackoverflow.com/questions/6463437/soap-client-for-android. You can find more by typing "Android SOAP client" into your favourite search engine – Henry Jul 28 '17 at 11:51
  • Thanks for the links, but it's posible make the request with Volley library? – Pypypy Jul 28 '17 at 12:04
  • Yes it is possible. A SOAP request is just a normal Web request after all. But it is somewhat tricky to assemble the request manually. If you have access to another client maybe you can inspect the XML that goes over the line. (There are specifications as well, but they are rather complex). – Henry Jul 28 '17 at 12:08

0 Answers0