locked
How to consume secure java webservice in Asp.net? RRS feed

  • Question

  • User-300120154 posted

    How to consume secure java webservice in Asp.net?

    Sunday, March 24, 2013 6:36 AM

Answers

  • User281315223 posted

    You should be able to consume the service much as like you would any other kind of web service as long as you don't run into any interoperability issues between the two.

    If you have the necessary WSDL file that actually describes your Java Web Service, then you can include a Web Reference within your Project in Visual Studio by right-clicking on your Project and selecting "Add Web Reference" or "Add Service Reference" (depending on your version of Visual Studio). See the links below for a few examples : 

    If the service is a SOAP Web Service, then you'll want to consume it as you would in the following tutorials : 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 24, 2013 8:53 AM
  • User281315223 posted

    You may want to take a look at the following tutorial on CodeProject :

    It basically details creating a custom class that you are going to use to pass your username and password within your SOAP Request to handle authentication.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 25, 2013 7:41 AM
  • User281315223 posted

    Did you see the link that I posted? It covers how to add the appropriate authentication credentials into the header of your Web Service Request. You can also check out Microsoft's basic example of Adding Security Credentials to a SOAP Message :

    //Create a UsernameToken to store your Credentials
    UsernameToken userToken = new UsernameToken(userName, password, PasswordOption.SendHashed);
    
    //Get the Context for the SOAP Request being made
    YourService serviceProxy = new YourService();
    SoapContext requestContext = serviceProxy.RequestSoapContext;
    
    //Add your credentials token to your Request
    requestContext.Security.Tokens.Add(userToken);
    
    //Call your actual Web Service
    serviceProxy.YourApproriateMethodHere();
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 25, 2013 11:09 AM

All replies

  • User281315223 posted

    You should be able to consume the service much as like you would any other kind of web service as long as you don't run into any interoperability issues between the two.

    If you have the necessary WSDL file that actually describes your Java Web Service, then you can include a Web Reference within your Project in Visual Studio by right-clicking on your Project and selecting "Add Web Reference" or "Add Service Reference" (depending on your version of Visual Studio). See the links below for a few examples : 

    If the service is a SOAP Web Service, then you'll want to consume it as you would in the following tutorials : 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 24, 2013 8:53 AM
  • User-300120154 posted

    Thanks Rion Williams,

    I have added that Java webservice in my project by right clicking Add Service Reference but its asking username and password for authentication when making request. so how to add that userid and password in soap header when requesting

    Monday, March 25, 2013 1:50 AM
  • User281315223 posted

    You may want to take a look at the following tutorial on CodeProject :

    It basically details creating a custom class that you are going to use to pass your username and password within your SOAP Request to handle authentication.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 25, 2013 7:41 AM
  • User-300120154 posted

    Web service already written in Java but its asking username and password for authentication

    So, how can pass that username and password to that java webservice

    Monday, March 25, 2013 10:30 AM
  • User281315223 posted

    Did you see the link that I posted? It covers how to add the appropriate authentication credentials into the header of your Web Service Request. You can also check out Microsoft's basic example of Adding Security Credentials to a SOAP Message :

    //Create a UsernameToken to store your Credentials
    UsernameToken userToken = new UsernameToken(userName, password, PasswordOption.SendHashed);
    
    //Get the Context for the SOAP Request being made
    YourService serviceProxy = new YourService();
    SoapContext requestContext = serviceProxy.RequestSoapContext;
    
    //Add your credentials token to your Request
    requestContext.Security.Tokens.Add(userToken);
    
    //Call your actual Web Service
    serviceProxy.YourApproriateMethodHere();
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 25, 2013 11:09 AM
  • User-300120154 posted

    I created it as you suggested above link but not getting serviceproxy.RequestSoapContext

    means not able to find RequestSoapContext

    Tuesday, March 26, 2013 12:05 AM