How to invoke Axis web service through a .NET client
I have a task to call and connect to Axis webservice in dotnet web application.
The web service first requires a username and password to be authenticated, which must be sent in the header, only after authenticating can we call any of its methods.
Now I don't know how to pass credentials and call the webservice.
I have Java code that shows how to access a webservice, but I don't know how to do the same in .NET.
I suppose I need to use WSE 3.0.
Here is the Java code:
Service webService = new Service();
Call calling = (Call) webService.createCall();
calling.setProperty (Call.USERNAME_PROPERTY, "victor");
calling.setProperty (Call.PASSWORD_PROPERTY, "victor_s");
String userid="userid";
String password="password";
String endpoint= "SERVICEURL";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName(new QName(endpoint,methodName));
call.setProperty (Call.USERNAME_PROPERTY, "victor");
call.setProperty (Call.PASSWORD_PROPERTY, "victor_s");
String ItineraryDetailsInputXML="<?xml version=\"1.0\" encoding=\"UTF-8\"?><ItineraryDetailsInput lccp_srcstn=\"NDLS\" lccp_dstnstn=\"MAS\" lccp_trnnum=\"2616\" lccp_cls=\"SL\" lccp_resupto=\"MAS\" lccp_brdpt=\"NDLS\" lccp_day=\"27\" lccp_month=\"11\" lccp_year=\"2008\" lccp_qta=\"GN\" lccp_psgnname1=\"SANJEEV KUMAR \" lccp_psgnsex1=\"m\" lccp_psgnage1=\"60\" lccp_psgnberthpref1=\"Side_Upper\" lccp_psgnfoodpref1=\"Veg\" lccp_psgnconc1=\"SRCTZN\" lccp_psgnname2=\"Prasad\" lccp_psgnsex2=\"f\" lccp_psgnage2=\"60\" lccp_psgnberthpref2=\"Side_Lower\" lccp_psgnfoodpref2=\"\" lccp_psgnconc2=\"SRCTNW\" lccp_psgnname3=\"saa\" lccp_psgnsex3=\"m\" lccp_psgnage3=\"05\" lccp_psgnberthpref3=\"\" lccp_psgnfoodpref3=\"\" lccp_psgnconc3=\"\" lccp_psgnname4=\"ssss\" lccp_psgnsex4=\"m\" lccp_psgnage4=\"45\" lccp_psgnberthpref4=\"\" lccp_psgnfoodpref4=\"\" lccp_psgnconc4=\"\" lccp_psgnname5=\"\" lccp_psgnsex5=\"\" lccp_psgnage5=\"\" lccp_psgnberthpref5=\"\" lccp_psgnfoodpref5=\"\" lccp_psgnconc5=\"\" lccp_psgnname6=\"\" lccp_psgnsex6=\"\" lccp_psgnage6=\"\" lccp_psgnberthpref6=\"\" lccp_psgnfoodpref6=\"\" lccp_psgnconc6=\"\" userid=\""+userid+"\" password=\""+password+"\"/>";
StringBuffer buffer = new StringBuffer ();
String requestXml=ItineraryDetailsInputXML;
I don't know how to accomplish all this credential transfer using .NET. Therefore, I ask you to please guide me on how I should decide this. Also, if you can, please give me some sample code in .NET where the above script could be done.
I wouldn't know without WSDL either, but I see no reason to use legacy code like WSE. Why do you think you need to do this?
Also, which version of .NET are you using? What have you tried?
Don't you know how to call an Axis service from .NET, or that you don't know how to call any service from .NET?
a source to share
Parse the WSDL in Visual Studio. Go to the Projects menu in the top menu → select Add Web Link or Add Service Link depending on the version of VS you have.
Then you just create a new customer in your code. The client will have something like "Client Credentials" where you pass the username / pw:
WebServiceClient client = new WebServiceClient();
client.ClientCredentials.UserName.UserName = "xyz";
client.ClientCredentials.UserName.Password = "123";
btw it doesn't matter that you connect to the AXYS web service. The whole point of a web service is to be able to use a standard so that the client doesn't matter.
a source to share