ozaka / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

Add support for MTOM #101

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Call web service which returns MTOM response

What is the expected output? What do you see instead?
Response should be read correctly. Error appears instead.

What version of the product are you using? On what operating system?
Android 2.3.4, Samsung Galaxy GIO S5660 (but it doesn't matter)

Original issue reported on code.google.com by lgrzy...@gmail.com on 16 Jan 2012 at 9:31

GoogleCodeExporter commented 8 years ago
You need to provide more detail at least. Ideally a potential example app and a 
patch that fixes it.. 

Original comment by mosa...@gmail.com on 16 Jan 2012 at 9:41

GoogleCodeExporter commented 8 years ago
It doesn't matter what web service I call. The key is that the web service 
returns MTOM response. ksoap2 says that the response is incorrect. I have no 
fix for that, but I have an idea. There could be one property which says what 
kind of response is expected. The response should be parsed in the way 
specified by the property.

Original comment by lgrzy...@gmail.com on 16 Jan 2012 at 9:55

GoogleCodeExporter commented 8 years ago
You could debug this with the source code from github and see. 

Original comment by mosa...@gmail.com on 16 Jan 2012 at 10:08

GoogleCodeExporter commented 8 years ago
Here is stacktrace

org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT 
--uuid:09543326...@5:13 in java.io.InputStreamReader@44f613e0) 
    at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
    at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1420)
    at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
    at org.ksoap2.transport.Transport.parseResponse(Transport.java:96)
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:189)
    at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:95)
    at my.package.client.pm.Engine.obtainExtraProjectIds(Engine.java:45)
    at my.package.activities.MainActivity$1.onClick(MainActivity.java:29)
    at android.view.View.performClick(View.java:2408)
    at android.view.View$PerformClick.run(View.java:8816)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)

And here is the code that creates the output above:
try {
 ht.call("obtainExtraProjectIds", envelope);
 if (envelope.getResponse() == null) {
  throw new Exception("Communication Error.");
 } else {
  returnMSG = "else";
 }
} catch (Exception ex) {
 if (returnMSG == null) {
  returnMSG = getStackTrace(ex); // getStackTrace converts ex.getStackTrace() to String
  System.out.println(returnMSG); // THE OUTPUT - STACKTRACE
 }
}

And here is the response (sniffed using wireshark):
HTTP/1.1 200 OK
Date: Tue, 17 Jan 2012 11:23:57 GMT
X-UA-Compatible: IE=7
Set-Cookie: JSESSIONID=BBA58CE2D7165ABED77824CE7AB66408; 
Path=/project-manager-gui; HttpOnly
Content-Type: multipart/related; type="application/xop+xml"; 
boundary="uuid:0c0c142c-26e6-41ce-af44-55889abde27e"; 
start="<root.message@cxf.apache.org>"; start-info="text/xml"
Content-Length: 1860
Connection: close

--uuid:0c0c142c-26e6-41ce-af44-55889abde27e
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:obtainExt
raProjectIdsResponse . . .

Original comment by lgrzy...@gmail.com on 17 Jan 2012 at 11:25

GoogleCodeExporter commented 8 years ago
That seems a problem deep down in kxml2. I dont have time or resources to debug 
but the source for it all is on github so feel free to take a stab at it.

Original comment by mosa...@gmail.com on 17 Jan 2012 at 4:45

GoogleCodeExporter commented 8 years ago
This is not xml parser problem. The problem is that Http Transport class does 
not parse MTOM message properly. It seems that HttpTransportSE.Parse passes 
body of the response directly to kxml2 while the correct way would be to parse 
MTOM message and pass extracted SOAP envelop to the parser. 

Original comment by andrius....@gmail.com on 27 Sep 2012 at 7:04

GoogleCodeExporter commented 8 years ago
Ok.. fair enough. I know nothing about MTOM so I guess I looked in the wrong 
place. If you know more it would be great if you could implement your 
suggestion and send a pull request with any required fixes/enhancements.

Original comment by mosa...@gmail.com on 27 Sep 2012 at 10:17

GoogleCodeExporter commented 8 years ago
I am working on implementing MTOM on KSOAP2. 

Basically the content-type for MTOM is multipart/related instead of xml. So the 
first thing is to identify by this if it is a MTOM response,then get the 
boundary (Which is the part separator) to parse individually each part, one of 
those is the XML soap response (the one with content-type containing xml) and 
the rest of the parts are the MTOM content that needs to be saved to disk for 
future reference

Original comment by jose.cas...@gmail.com on 30 Aug 2014 at 2:30

GoogleCodeExporter commented 8 years ago
MTOM SOAP messages explanation

https://blogs.oracle.com/sujit/entry/mtom_soap_with_attachment_in

Original comment by jose.cas...@gmail.com on 30 Aug 2014 at 2:32

GoogleCodeExporter commented 8 years ago
I'm a main developer in http://easywsdl.com. We are working on MTOM 
implementation for ksoap2 library. We are going to publish our extensions to 
ksoap2 as a separate library but for now if you need MTOM transfer, you will 
find a working solution in http://easywsdl.com.

Original comment by roman...@gmail.com on 13 Jan 2015 at 10:42

GoogleCodeExporter commented 8 years ago
Feel free to provide the MTOM implementation as a pull request to this project 
as well to make things easier for users. Provided of course this works for you 
in terms of project flow and license.

Original comment by mosa...@gmail.com on 13 Jan 2015 at 6:17

GoogleCodeExporter commented 8 years ago
Is this issued solved ? I get the same problem here. I already download the 
newest version 3.4 and still get the error. Or maybe I'm missing some new 
function ? thanks..

Original comment by nicotobe...@gmail.com on 22 Jul 2015 at 2:47

GoogleCodeExporter commented 8 years ago
The project is migrating to github. If you believe this issue is still valid 
and should be tracked please file a new issue at 
https://github.com/simpligility/ksoap2-android/issues

Original comment by mosa...@gmail.com on 7 Aug 2015 at 5:35