K
Kumar
Hi,
I have a web service running at
http://localhost:8080/Hello/HelloService
and I have a method getHello( ).
If I want to access this through .NET [C#] client, what should I do?
The following code that I modified based on a site did not work for me. Any
ideas?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Web.Services.Protocols;
using System.Web.Services;
[System.Web.Services.WebServiceBindingAttribute(
Name = "HelloService",
Namespace = "urn:HelloService")]
/// <summary>
/// Summary description for testjavaservice
/// </summary>
public class testjavaservice :
System.Web.Services.Protocols.SoapHttpClientProtocol
{
public testjavaservice()
{
//
// TODO: Add constructor logic here
//
this.Url = http://localhost:8080/Hello/HelloService;
}
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:HelloService/getHello",
RequestNamespace = "urn:HelloService",
ResponseNamespace = "urn:HelloService",
Use = System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle =
System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string getHello (string name)
{
object[] results = this.Invoke("getHello", new object[] { name });
return ( (string) results[0]);
}
public static void Main(String[] args)
{
try
{
Console.WriteLine("Calling the SOAP server to say hello");
testjavaservice jsvc = new testjavaservice();
Console.WriteLine("The SOAP server says " +
jsvc.getHello(args[0]));
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
Thanks
- Kumar
I have a web service running at
http://localhost:8080/Hello/HelloService
and I have a method getHello( ).
If I want to access this through .NET [C#] client, what should I do?
The following code that I modified based on a site did not work for me. Any
ideas?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Web.Services.Protocols;
using System.Web.Services;
[System.Web.Services.WebServiceBindingAttribute(
Name = "HelloService",
Namespace = "urn:HelloService")]
/// <summary>
/// Summary description for testjavaservice
/// </summary>
public class testjavaservice :
System.Web.Services.Protocols.SoapHttpClientProtocol
{
public testjavaservice()
{
//
// TODO: Add constructor logic here
//
this.Url = http://localhost:8080/Hello/HelloService;
}
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:HelloService/getHello",
RequestNamespace = "urn:HelloService",
ResponseNamespace = "urn:HelloService",
Use = System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle =
System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string getHello (string name)
{
object[] results = this.Invoke("getHello", new object[] { name });
return ( (string) results[0]);
}
public static void Main(String[] args)
{
try
{
Console.WriteLine("Calling the SOAP server to say hello");
testjavaservice jsvc = new testjavaservice();
Console.WriteLine("The SOAP server says " +
jsvc.getHello(args[0]));
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
Thanks
- Kumar