如何通过 .NET 客户端调用 Axis Web 服务

发布于 2024-07-20 16:59:02 字数 2273 浏览 8 评论 0原文

我有一个任务要调用 & 连接到 dotnet Web 应用程序中的 Axis Web 服务。

Web服务首先需要验证用户名和密码 密码,应该在标头中发送,只有经过身份验证后,我们才能调用它的任何方法。

现在,我不知道如何传递凭据和信息。 调用网络服务。

我有显示如何访问 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中的示例代码,其中上述场景可以是 完毕。

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

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

Now, I don't know how to pass the credentials & invoke the webservice.

I have the Java code which shows how to access the webservice, but I don't know how to do the same in .NET.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沐歌 2024-07-27 16:59:02

如果没有 WSDL,我也不知道,但我认为您没有理由使用像 WSE 这样过时的代码。 你认为你为什么必须这么做?

另外,您使用的 .NET 版本是什么? 你尝试过什么?

是否您不知道如何从 .NET 调用 Axis 服务,或者您不知道如何从 .NET 调用任何服务?

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?

终难遇 2024-07-27 16:59:02

在 Visual Studio 中解析 WSDL。 转到顶部菜单中的“项目”菜单 -> 根据您拥有的 VS 版本选择“添加 Web 引用”或“添加服务引用”。

然后您只需在代码中创建一个新客户端即可。 客户端将有类似“客户端凭据”的内容,您可以将用户名/密码传递到其中:

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

顺便说一句,您连接到 AXYS Web 服务并不重要。 Web 服务的重点是能够使用标准,这样客户端就不再重要了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文