View Single Post
  (#4 (permalink)) Old
jeckerlin Offline
New Member
 
Posts: 6
Join Date: Jul 2008
Model: 8100
PIN: N/A
Carrier: tombile
Default 07-18-2008, 07:29 PM

User a complex type from a .net web service:

java:
String serviceUrl = "h t t p://192.168.0.103/BBService/Service1.asmx";
String serviceNamespace = "h t t p//tempuri.org/";
String soapAction = "h t t p://tempuri.org/HelloWorldComplexType";
String methodName = "HelloWorldComplexType";

SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("Name", "Jeff");
rpc.addProperty("Password", "nonya");

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;

try
{
ht.call(soapAction, envelope);
result = (envelope.getResult()).toString();
}
catch(org.xmlpull.v1.XmlPullParserException ex2){

}
catch(Exception ex){
String bah = ex.toString();
}

.net web service:
namespace TestService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "h t t p://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod]
public string HelloWorld()
{
return "Hello World" + System.DateTime.Now.ToString();
}

[WebMethod]
public string HelloWorldParam(string Name)
{
return "Hello " + Name;
}


[WebMethod]
public user HelloWorldComplexType(string Name, string Password)
{
user myUser = new user(Name, Password);

return myUser;
}

public class user
{
public user()
{


}

public user(string name, string pwd)
{
usrName = name;
usrPassword = pwd;
}

public string usrName { get; set; }

public string usrPassword { get; set; }
}
}
}
   
Reply With Quote