tags:

views:

641

answers:

2

Hi ,

I have a task to invoke & connect to a axis webservice in a dotnet web app.

The weservice, first requires authentication of username & password , which should be sent in header , only after authenication , we can call any of its method.

Now , i actually i dont know , how to actually pass the credentials & invoke the webservice.

I have the java code , which shows how to access the webservice , but i dont know how to do the same in dotnet .

I suppose i have 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 dont know , how to do all this passing of credentials using dotet. Hence , i request you to please guide me , on how should i tackle this. Also , if u can please give me some sample code in dontet , where the above scenario can be done.

Regards Victor

A: 

I wouldn't know either, without the WSDL, but I see no reason for you to use obsolete code like WSE. Why do you think you'd have to do that?

Also, what version of .NET are you using? What have you tried?

Is it that you don't know how to call an Axis service from .NET, or that you don't know how to call any service from .NET?

John Saunders
Hi John,Thanks 4 ur reply.Actually , i have to call a axis webservive which needs to be first invoked using username, password(see java code above).Now i serched on net on how to pass credentials to the axis webservice, so i ended up using wse 3.0(In that it has UserNameTokens).I am using VS2005 , but can also use VS2008 if required.Also, mainly i am a Sharepoint guy , so i have worked mainly with dotnet webservice , which uses network credentials.Url of test webservice is :http://202.93.154.18/webservices1.7/serviceSee the java code above ,how can i do it in dotnet
I can't access that service. It times out. However, here's a very important hint. If you ever see the term "WSE", you should pretend that it says "PLAGUE" instead. It is obsolete, is not being developed, and is barely being supported. I truly do not understand why MS doesn't just tell you that. But since I don't work for them, _I_ can tell you - DON'T DO IT. Try WCF instead. WCF is the replacement for WSE, ASMX web services, and a lot more.
John Saunders
hi John,Thanks 4 ur reply..Yaa , jst by goin thru the documentation on WSE ..its indeed a PLAGUE , but m not getting any other way..Also , the webservice reqires that the object which invokes the service, should have proper credentails , can we do it in WCF?Because , the service itself doesnot have any method for auhenticatin , jst the object which is invoking it , should have credentails .
As I said, WCF has all the features of WSE and ASMX and Remoting, and a lot more. WSE was largely an interim technology that has now been replaced. You're best to pretend it never existed. You have found a perfect example of why the use of Google is problematic - the article you found was not marked with "WSE is obsolete, so don't use it", because when it was written, WSE was not obsolete.
John Saunders
A: 

Parse the WSDL in Visual Studio. Go to 'Projects' Menu along the top menu -> choose 'Add Web Reference' or 'Add service reference' depending on what version of VS you have.

Then you just make a new Client in your code. The Client will have something like 'Client Credentials' where you pass the username/pw into that:

WebServiceClient client = new WebServiceClient();
client.ClientCredentials.UserName.UserName = "xyz";
client.ClientCredentials.UserName.Password = "123";

btw it should not matter that you are connecting to an AXYS web service. The whole point of a web service is to be able to use a standard so that the client does not matter.

jle

related questions