|

07-18-2008, 06:19 PM
Here is another example passing in a simple string parameter:
java:
String serviceUrl = <url to web service>;
String serviceNamespace = "h t tp ://tempuri.org/";
String soapAction = h t tp://tempuri.org/HelloWorldParam";
String methodName = "HelloWorldParam";
SoapObject rpc = new SoapObject(serviceNamespace, methodName);
rpc.addProperty("Name", "Jeff");
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 tp : //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;
}
}
}
|