How to access a webservice in java through .NET client

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top