How to access a webservice in java through .NET client

Discussion in 'ASP .Net Web Services' started by Kumar, Oct 19, 2008.

  1. Kumar

    Kumar Guest

    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
     
    Kumar, Oct 19, 2008
    #1
    1. Advertising

  2. John Saunders, Oct 19, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Henry
    Replies:
    5
    Views:
    10,057
    Steven Cheng[MSFT]
    Aug 3, 2004
  2. Mr. x
    Replies:
    2
    Views:
    729
    Andrew
    Oct 10, 2003
  3. JC
    Replies:
    3
    Views:
    601
    =?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=
    Jun 19, 2006
  4. narasimham
    Replies:
    0
    Views:
    179
    narasimham
    Nov 20, 2003
  5. JD
    Replies:
    5
    Views:
    283
    Lalitha
    Oct 7, 2004
Loading...

Share This Page