olupotd / ksoap2-android

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

WCF Service hosted in IIS (SVC File) cannot be consumed by ksoap2? #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I would like to consume a WCF Service in Eclipse for an Android app.

I have successfully done this with .asmx, based service. However would like to 
use a new .SVC based service instead.(WCF Service hosted through IIS)  

I've tried ksoap2 hitting the url like
http://machine/AppName/ServiceName.svc?wsdl

or http://machine/AppName/ServiceName.svc

It gives me

org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT 
null@1:0 in java.io.InputStreamReader@44ebb7e0)

I've made sure that the WCF Service is SOAP 1.1 based.
I have Eclipse Galileo and the ADT Plugin v0.97 running on Windows XP

If I use WireShark to sniff the packets I see

HTTP/1.1 415 Cannot process the message because the content type 'text/xml' was 
not the expected type 'application/soap+xml; charset=utf-8'.\r\n

SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);

seems as though the Soap implementation is HTTP GET, which is not supported 
with the WCF through IIS.   

Are there plans for ksoap2 to support this ?

Original issue reported on code.google.com by ddudl...@gmail.com on 28 Jul 2010 at 12:13

GoogleCodeExporter commented 9 years ago
I have the same problem with WCF service. Similar .NET web-Service (.asmx) 
works fine.
Does anybody know how to solve this?

Original comment by babl...@gmail.com on 26 Sep 2010 at 4:16

GoogleCodeExporter commented 9 years ago
What kind of data is the WCF service returning?
Can you call the endpoint using the WCF Service Test Client?
Can you host in a Windows service instead of IIS?

I have a demo service that returns a List<Order> from an Entity Framework 
model. The WCF Service Test Client refuses to call it, complaining that it 
returns an Order[]. It returns an empty response object to Android which 
triggers the XmlPullParser: unexpected type exception.

I changed the service to return a List<OrderMirror> where OrderMirror is a POCO 
that 'mirrors' the properties of the Order class and is decorated with 
DataContract and DataMember attributes. I use some code to create the 
List<OrderMirror> collection and return that from the service. The WCF Service 
Test Client will now consume it and it returns a proper response object to 
Android. I'm also hosting this demo service in a console app rather than IIS; 
it should work as a Windows Service as well. This is .NET 4.0 with EF4, BTW.

Based on my research I'm not sure it's a ksoap2-android problem as it looks 
like many platforms have the problem (Blackberry programmers seem to run into 
it frequently.) Depending on how your services are architected you may have to 
write wrappers around them to support Android clients. If you're going to have 
to do that you might want to consider using JSON instead (which is much lighter 
than SOAP.)

Original comment by Roger.H...@gmail.com on 30 Sep 2010 at 3:08

GoogleCodeExporter commented 9 years ago
Hell, Riger.

> What kind of data is the WCF service returning?

namespace SampleService
{
    [ServiceContract]
    public interface ISampleService
    {
        [OperationContract]
        double Add(double a, double b, String c);
    }
}

> Can you call the endpoint using the WCF Service Test Client?

As far as I can see from MSDN, WCF service test client should come with VS but 
my VS distro does not contain this tool. I can access this service from other 
.NET app.

> Can you host in a Windows service instead of IIS?

I'm hosting WCF service in console application, not in IIS.

---
In fact, I'm trying to access simplest service which returns standard data 
types but have no success with this.

> If you're going to have to do that you might want to consider using JSON 
instead (which is much lighter than SOAP.)

I need a functionality which will allow to notify all connected clients on some 
events (e.g functionality similar to chat, when server receives a message, it 
re-sends it to all connected clients. I'm not sure that if I use JSON API and 
will not keep connection open, I will be able to have such functionality.

I can upload the source code of my Java test app and WCF service if needed.

Thanks.

Original comment by babl...@gmail.com on 30 Sep 2010 at 3:43

GoogleCodeExporter commented 9 years ago
Normally WCF won't keep any connection open. It's designed that the client 
requests some data from the service (perhaps sending some as well) then the 
service responds and the connection closes. I believe the type of connection 
you are speaking about is what's called a Duplex WCF Service 
(http://msdn.microsoft.com/en-us/library/ms731064.aspx) in which both the 
client and server can initiate a connection to the other party. I've never 
built one of these so I don't know the details of them and I certainly don't 
know how Android would fit in the picture. I would imagine there would be 
battery issues and loss-of-connection handling issues.

WCF Service Test client should be in C:\Program Files (x86)\Microsoft Visual 
Studio 10.0\Common7\IDE\WcfTestClient.exe. It's included in my VS2010 
Professional; if you only have the Express version it's possible it's not 
included there.

Json vs. Soap is irrelevant; neither keeps a connection open. They are simply 
the means to communicate the data.

Original comment by Roger.H...@gmail.com on 30 Sep 2010 at 7:55

GoogleCodeExporter commented 9 years ago
Hello ddudl..gmail.com
 Would you post the reguarl asmx.
 using kSOAP i code build and permissions also , but still the Envelope is null.
 and cant get it working
 Can you send code which is working with asmx

 Rayudu Addagarla

Original comment by rayud...@gmail.com on 3 Jan 2012 at 7:20

GoogleCodeExporter commented 9 years ago
Don't think I ever got ksoap to work right in this situation.  I no longer
have access to the code I created.  Sorry!

Original comment by ddudl...@gmail.com on 4 Jan 2012 at 1:58

GoogleCodeExporter commented 9 years ago
I have the same problem with android 2.2 but not with android 4.0.3...

see : 
http://stackoverflow.com/questions/8969893/android-ksoap-2-2-6-web-service-with-
android-2-2-version-ko-and-not-with-andro

Original comment by benjamin...@gmail.com on 23 Jan 2012 at 10:41

GoogleCodeExporter commented 9 years ago
I have the same issue when using android 2.2 and a SVC file, major annoying.. 
:-(

Original comment by dettamin...@gmail.com on 13 Feb 2012 at 8:32

GoogleCodeExporter commented 9 years ago
It seems to be working from posts on stackoverflow and other places so this is 
not a ksoap issue as far as I can tell. 

Original comment by mosa...@gmail.com on 30 Apr 2012 at 6:22

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
@jacek.makiela .. is this your app? and is it using ksoap2-android?

Original comment by mosa...@gmail.com on 7 Sep 2012 at 10:08

GoogleCodeExporter commented 9 years ago
Check out the application WCF Tester and WCF Tester Pro for debugging. It uses 
ksoap2-android and works with WCF services. See more at 
http://code.google.com/p/ksoap2-android/wiki/ProjectsUsingKsoap2Android

Original comment by mosa...@gmail.com on 13 Sep 2012 at 5:09