【发布时间】:2012-02-14 19:21:00
【问题描述】:
我的任务是调用和连接到 dotnet Web 应用程序中的 Axis Web 服务。
webservice,首先需要用户名和密码的认证,应该在header中发送,只有认证后,我们才能调用它的任何方法。
现在,我不知道如何传递凭据和调用网络服务。
我有显示如何访问 web 服务的 Java 代码,但我不知道如何在 .NET 中执行相同操作。
我想我必须使用 WSE 3.0。
这是Java代码:
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;
我不知道如何使用 .NET 完成所有这些凭据传递。 因此,我请求您指导我,我应该如何解决这个问题。 另外,如果可以的话,请给我一些.NET中的示例代码,上面的场景可以在哪里 完成。
【问题讨论】:
标签: .net web-services axis