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. Advertisements

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

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. Samuel
    Replies:
    0
    Views:
    661
    Samuel
    Jul 30, 2003
  2. Brian Henry
    Replies:
    5
    Views:
    10,229
    Steven Cheng[MSFT]
    Aug 3, 2004
  3. aatif
    Replies:
    5
    Views:
    4,021
    Jeff Dillon
    Nov 23, 2004
  4. Mr. x
    Replies:
    2
    Views:
    852
    Andrew
    Oct 10, 2003
  5. F Stifter
    Replies:
    0
    Views:
    1,253
    F Stifter
    Nov 30, 2005
  6. JC
    Replies:
    3
    Views:
    726
    =?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=
    Jun 19, 2006
  7. narasimham
    Replies:
    0
    Views:
    244
    narasimham
    Nov 20, 2003
  8. JD
    Replies:
    5
    Views:
    517
    Lalitha
    Oct 7, 2004
Loading...