Yes I am posting yet another ksoap2 thread...I apologize in advance!
I can succesfully call a .Net (ASP.net 2.0) webservice with ksoap2 without parameters and recieve the expected response. I cannot however get a .Net webservice to accept parameters from ksoap2. Just so you know that I'm not just blasting out an unaswered question I have searched all over and come up with the following unaswered threads of this same exact issues (sorry I cannot post links):
blackberryforums.com/developer-forum/43342-ksoap-net-parameters.html
blackberryforums.com/developer-forum/136630-pass-parmeters-net-webservice-using-ksoap2.html
blackberryforums.com/blackberry-network/125169-jde-soap-request-net-web-service.html
discussion.forum.nokia.com/forum/showthread.php?t=131532
There seems to be some confusion whether this is a ksoap2 issue or a .Net webservice issue. I'm also curious if there is some finallity on what attributes are required on the .Net web service side to get ksoap2 to work with parameters.
I have the following client code:
Code:
private void callRegWebService()
{
String serviceUrl = "h t t p : / / myurl/myservice.asmx";
String serviceNamespace = "h t t p : / / w w w . mynamespace.com";
String soapAction = "h t t p : / / w w w . mynamespace.com/HelloBBerry";
String methodName = "HelloBBerry";
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("DeviceID","Sent From BlackBerry!");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
String result = null;
String request = null;
String response = null;
try
{
ht.call(soapAction, envelope);
result = (envelope.getResult()).toString();
request = ht.requestDump;
response = ht.responseDump;
System.out.println(request);
if (result.toLowerCase().equals("true")){
_isRegistered = true;
}
}
catch(org.xmlpull.v1.XmlPullParserException ex2){
}
catch(Exception ex){
String bah = ex.toString();
}
}
I have the following .Net web service:
Code:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
<System.Web.Services.WebService(Namespace:="h t t p : / / w w w . mynamespace.com/")> _
Public Class trackberry
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloBBerry(ByVal DeviceID As String) As String
Return "BBerry Device ID: " & DeviceID
End Function
End Class
Some threads indicate that adding <SoapRpcMethod()> attribute to the method is required. However when I do this the call completely fails with a:
SoapFault - faultcode: 'soap:Client' faultstring: 'Server was unable to read request. ---> There is an error in XML document (1, 233). ---> <HelloBBerry xmlns='h t t p : / / w w w . mynamespace.com'> was not expected.' faultactor: 'null' detail: org.kxml2.kdom.Node@185ad2ec
I've also tried using the <SoapRpcService()> attribute at the class level with the same results.
If I remove the <SoapRpcMethod()> attribute as the code is posted above the call does not through an exception but the parameter is not recieved by the web service.
Has anybody gotten ksoap2 to work with .NET parameters and if so could you share with the community how you got this to work? Thanks in advance.