How to parse a complex object with ksoap2?
up vote
0
down vote
favorite
I'm using Android Studio and ksoap2 (version 3.6.2) to connect to a soap web service and i get a SoapObject in return but not as expected. I'm having problems creating the code for the nested properties inside the xml request. The webservice always send the same response even adding properties to the request (The .xml request works fine on SoapUI and the webservice sends the correct response).
Here is the .xml that i need to send from Android:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
<SelectionByID>
<Code>I</Code>
<TypeCode>1</TypeCode>
<ID>IM-640</ID>
</SelectionByID>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
And here is the code in Android:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject SelectionByID = new SoapObject(NAMESPACE, "SelectionByID");
SelectionByID .addProperty("Code", "I");
SelectionByID .addProperty("TypeCode", "1");
SelectionByID .addProperty("ID", "IM-640-1045");
SoapObject MaterialSelectionByElements = new SoapObject(NAMESPACE,"MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request.addSoapObject(MaterialSelectionByElements);
But the webservice always send the response as if i should be sending this on the request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
Please, any help would be very appreciated. Thanks in advance!
Note: I have already checked the Namespace, MethodName and URL in the request.
Please, help.
android-studio soap xml-parsing android-ksoap2 ksoap
add a comment |
up vote
0
down vote
favorite
I'm using Android Studio and ksoap2 (version 3.6.2) to connect to a soap web service and i get a SoapObject in return but not as expected. I'm having problems creating the code for the nested properties inside the xml request. The webservice always send the same response even adding properties to the request (The .xml request works fine on SoapUI and the webservice sends the correct response).
Here is the .xml that i need to send from Android:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
<SelectionByID>
<Code>I</Code>
<TypeCode>1</TypeCode>
<ID>IM-640</ID>
</SelectionByID>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
And here is the code in Android:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject SelectionByID = new SoapObject(NAMESPACE, "SelectionByID");
SelectionByID .addProperty("Code", "I");
SelectionByID .addProperty("TypeCode", "1");
SelectionByID .addProperty("ID", "IM-640-1045");
SoapObject MaterialSelectionByElements = new SoapObject(NAMESPACE,"MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request.addSoapObject(MaterialSelectionByElements);
But the webservice always send the response as if i should be sending this on the request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
Please, any help would be very appreciated. Thanks in advance!
Note: I have already checked the Namespace, MethodName and URL in the request.
Please, help.
android-studio soap xml-parsing android-ksoap2 ksoap
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I'm using Android Studio and ksoap2 (version 3.6.2) to connect to a soap web service and i get a SoapObject in return but not as expected. I'm having problems creating the code for the nested properties inside the xml request. The webservice always send the same response even adding properties to the request (The .xml request works fine on SoapUI and the webservice sends the correct response).
Here is the .xml that i need to send from Android:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
<SelectionByID>
<Code>I</Code>
<TypeCode>1</TypeCode>
<ID>IM-640</ID>
</SelectionByID>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
And here is the code in Android:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject SelectionByID = new SoapObject(NAMESPACE, "SelectionByID");
SelectionByID .addProperty("Code", "I");
SelectionByID .addProperty("TypeCode", "1");
SelectionByID .addProperty("ID", "IM-640-1045");
SoapObject MaterialSelectionByElements = new SoapObject(NAMESPACE,"MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request.addSoapObject(MaterialSelectionByElements);
But the webservice always send the response as if i should be sending this on the request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
Please, any help would be very appreciated. Thanks in advance!
Note: I have already checked the Namespace, MethodName and URL in the request.
Please, help.
android-studio soap xml-parsing android-ksoap2 ksoap
I'm using Android Studio and ksoap2 (version 3.6.2) to connect to a soap web service and i get a SoapObject in return but not as expected. I'm having problems creating the code for the nested properties inside the xml request. The webservice always send the same response even adding properties to the request (The .xml request works fine on SoapUI and the webservice sends the correct response).
Here is the .xml that i need to send from Android:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
<SelectionByID>
<Code>I</Code>
<TypeCode>1</TypeCode>
<ID>IM-640</ID>
</SelectionByID>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
And here is the code in Android:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapObject SelectionByID = new SoapObject(NAMESPACE, "SelectionByID");
SelectionByID .addProperty("Code", "I");
SelectionByID .addProperty("TypeCode", "1");
SelectionByID .addProperty("ID", "IM-640-1045");
SoapObject MaterialSelectionByElements = new SoapObject(NAMESPACE,"MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request.addSoapObject(MaterialSelectionByElements);
But the webservice always send the response as if i should be sending this on the request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org /soap/envelope/" xmlns:glob="http://abc.def">
<soapenv:Header/>
<soapenv:Body>
<glob:MaterialByElements>
<MaterialSelectionByElements>
</MaterialSelectionByElements>
</glob:MaterialByElements>
</soapenv:Body>
</soapenv:Envelope>
Please, any help would be very appreciated. Thanks in advance!
Note: I have already checked the Namespace, MethodName and URL in the request.
Please, help.
android-studio soap xml-parsing android-ksoap2 ksoap
android-studio soap xml-parsing android-ksoap2 ksoap
asked Nov 2 at 2:03
Adan Cordero
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
After a lot of research i found the answer. I am working with a SAP webservice and Android Handhelds. To achieve the xml request with ksoap2 i had to use this to create the SoapObject:
SoapObject request = null;
SoapObject SelectionByID = new SoapObject(null, "SelectionByID");
SelectionByID.addProperty("Code", "I");
SelectionByID.addProperty("TypeCode", "1");
SelectionByID.addProperty("ID", "IM-640");
SoapObject MaterialSelectionByElements = new SoapObject("", "MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request=MaterialSelectionByElements;
But it seems that the ksoap2 serialization use the
http://www.w3.org/2001/XMLSchema-instance eschema by default. So i had to serialize on the SAP way using this class:
public static class SAPSerializationEnvelope extends SoapSerializationEnvelope
public String namespace;
public SAPSerializationEnvelope(int version, String namespace)
super(version);
this.namespace= namespace;
@Override
public void write(XmlSerializer writer) throws IOException
writer.setPrefix("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
writer.setPrefix("glob", namespace);
writer.setPrefix("soapenv", env);
writer.startTag(env, "Envelope");
writer.startTag(env, "Header");
writeHeader(writer);
writer.endTag(env, "Header");
writer.startTag(env, "Body");
writer.setPrefix("glob", namespace);
writer.startTag(namespace, "MaterialByElementsQuery_sync");
writeBody(writer);
writer.endTag(namespace, "MaterialByElementsQuery_sync");
writer.endTag(env, "Body");
writer.endTag(env, "Envelope");
@Override
public Object getResponse() throws SoapFault
return super.getResponse();
And thats it. The xml is the expected one by the webservice. I still don´t know why the SAP webservices are still using SOAP instead of Restful services. We are in 2018 and this kind of webservices looks a little bit old.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
After a lot of research i found the answer. I am working with a SAP webservice and Android Handhelds. To achieve the xml request with ksoap2 i had to use this to create the SoapObject:
SoapObject request = null;
SoapObject SelectionByID = new SoapObject(null, "SelectionByID");
SelectionByID.addProperty("Code", "I");
SelectionByID.addProperty("TypeCode", "1");
SelectionByID.addProperty("ID", "IM-640");
SoapObject MaterialSelectionByElements = new SoapObject("", "MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request=MaterialSelectionByElements;
But it seems that the ksoap2 serialization use the
http://www.w3.org/2001/XMLSchema-instance eschema by default. So i had to serialize on the SAP way using this class:
public static class SAPSerializationEnvelope extends SoapSerializationEnvelope
public String namespace;
public SAPSerializationEnvelope(int version, String namespace)
super(version);
this.namespace= namespace;
@Override
public void write(XmlSerializer writer) throws IOException
writer.setPrefix("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
writer.setPrefix("glob", namespace);
writer.setPrefix("soapenv", env);
writer.startTag(env, "Envelope");
writer.startTag(env, "Header");
writeHeader(writer);
writer.endTag(env, "Header");
writer.startTag(env, "Body");
writer.setPrefix("glob", namespace);
writer.startTag(namespace, "MaterialByElementsQuery_sync");
writeBody(writer);
writer.endTag(namespace, "MaterialByElementsQuery_sync");
writer.endTag(env, "Body");
writer.endTag(env, "Envelope");
@Override
public Object getResponse() throws SoapFault
return super.getResponse();
And thats it. The xml is the expected one by the webservice. I still don´t know why the SAP webservices are still using SOAP instead of Restful services. We are in 2018 and this kind of webservices looks a little bit old.
add a comment |
up vote
0
down vote
After a lot of research i found the answer. I am working with a SAP webservice and Android Handhelds. To achieve the xml request with ksoap2 i had to use this to create the SoapObject:
SoapObject request = null;
SoapObject SelectionByID = new SoapObject(null, "SelectionByID");
SelectionByID.addProperty("Code", "I");
SelectionByID.addProperty("TypeCode", "1");
SelectionByID.addProperty("ID", "IM-640");
SoapObject MaterialSelectionByElements = new SoapObject("", "MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request=MaterialSelectionByElements;
But it seems that the ksoap2 serialization use the
http://www.w3.org/2001/XMLSchema-instance eschema by default. So i had to serialize on the SAP way using this class:
public static class SAPSerializationEnvelope extends SoapSerializationEnvelope
public String namespace;
public SAPSerializationEnvelope(int version, String namespace)
super(version);
this.namespace= namespace;
@Override
public void write(XmlSerializer writer) throws IOException
writer.setPrefix("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
writer.setPrefix("glob", namespace);
writer.setPrefix("soapenv", env);
writer.startTag(env, "Envelope");
writer.startTag(env, "Header");
writeHeader(writer);
writer.endTag(env, "Header");
writer.startTag(env, "Body");
writer.setPrefix("glob", namespace);
writer.startTag(namespace, "MaterialByElementsQuery_sync");
writeBody(writer);
writer.endTag(namespace, "MaterialByElementsQuery_sync");
writer.endTag(env, "Body");
writer.endTag(env, "Envelope");
@Override
public Object getResponse() throws SoapFault
return super.getResponse();
And thats it. The xml is the expected one by the webservice. I still don´t know why the SAP webservices are still using SOAP instead of Restful services. We are in 2018 and this kind of webservices looks a little bit old.
add a comment |
up vote
0
down vote
up vote
0
down vote
After a lot of research i found the answer. I am working with a SAP webservice and Android Handhelds. To achieve the xml request with ksoap2 i had to use this to create the SoapObject:
SoapObject request = null;
SoapObject SelectionByID = new SoapObject(null, "SelectionByID");
SelectionByID.addProperty("Code", "I");
SelectionByID.addProperty("TypeCode", "1");
SelectionByID.addProperty("ID", "IM-640");
SoapObject MaterialSelectionByElements = new SoapObject("", "MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request=MaterialSelectionByElements;
But it seems that the ksoap2 serialization use the
http://www.w3.org/2001/XMLSchema-instance eschema by default. So i had to serialize on the SAP way using this class:
public static class SAPSerializationEnvelope extends SoapSerializationEnvelope
public String namespace;
public SAPSerializationEnvelope(int version, String namespace)
super(version);
this.namespace= namespace;
@Override
public void write(XmlSerializer writer) throws IOException
writer.setPrefix("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
writer.setPrefix("glob", namespace);
writer.setPrefix("soapenv", env);
writer.startTag(env, "Envelope");
writer.startTag(env, "Header");
writeHeader(writer);
writer.endTag(env, "Header");
writer.startTag(env, "Body");
writer.setPrefix("glob", namespace);
writer.startTag(namespace, "MaterialByElementsQuery_sync");
writeBody(writer);
writer.endTag(namespace, "MaterialByElementsQuery_sync");
writer.endTag(env, "Body");
writer.endTag(env, "Envelope");
@Override
public Object getResponse() throws SoapFault
return super.getResponse();
And thats it. The xml is the expected one by the webservice. I still don´t know why the SAP webservices are still using SOAP instead of Restful services. We are in 2018 and this kind of webservices looks a little bit old.
After a lot of research i found the answer. I am working with a SAP webservice and Android Handhelds. To achieve the xml request with ksoap2 i had to use this to create the SoapObject:
SoapObject request = null;
SoapObject SelectionByID = new SoapObject(null, "SelectionByID");
SelectionByID.addProperty("Code", "I");
SelectionByID.addProperty("TypeCode", "1");
SelectionByID.addProperty("ID", "IM-640");
SoapObject MaterialSelectionByElements = new SoapObject("", "MaterialSelectionByElements");
MaterialSelectionByElements.addSoapObject(SelectionByID);
request=MaterialSelectionByElements;
But it seems that the ksoap2 serialization use the
http://www.w3.org/2001/XMLSchema-instance eschema by default. So i had to serialize on the SAP way using this class:
public static class SAPSerializationEnvelope extends SoapSerializationEnvelope
public String namespace;
public SAPSerializationEnvelope(int version, String namespace)
super(version);
this.namespace= namespace;
@Override
public void write(XmlSerializer writer) throws IOException
writer.setPrefix("soapenv", "http://schemas.xmlsoap.org/soap/envelope/");
writer.setPrefix("glob", namespace);
writer.setPrefix("soapenv", env);
writer.startTag(env, "Envelope");
writer.startTag(env, "Header");
writeHeader(writer);
writer.endTag(env, "Header");
writer.startTag(env, "Body");
writer.setPrefix("glob", namespace);
writer.startTag(namespace, "MaterialByElementsQuery_sync");
writeBody(writer);
writer.endTag(namespace, "MaterialByElementsQuery_sync");
writer.endTag(env, "Body");
writer.endTag(env, "Envelope");
@Override
public Object getResponse() throws SoapFault
return super.getResponse();
And thats it. The xml is the expected one by the webservice. I still don´t know why the SAP webservices are still using SOAP instead of Restful services. We are in 2018 and this kind of webservices looks a little bit old.
answered Nov 10 at 4:06
Adan Cordero
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53111769%2fhow-to-parse-a-complex-object-with-ksoap2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown