未知WebService的描述和从C#使用它 [英] Unknown WebService description and consume it from C#

查看:198
本文介绍了未知WebService的描述和从C#使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相当一noob,并已制定从几个月勉强的'严重'(因为我的工作),所以我提前为我的无知道歉。

I'm quite a noob and have been developing 'seriously' (as my job) from a couple of months barely, so i apologize in advance for my ignorance.

有是,我需要从C#客户端使用一个aspx页面我想开发这个Web服务,但首先我需要了解web服务,我不知道它在做它的语言,但我认为这是PERL由于Web服务的URL是这样的 http://wschsol.mideplan.cl / mod_perl的/ XML / FPS-通过车辙。此WebService是由其他人,我现在不能联系和我没有访问任何一台Linux服务器上运行开发的。

There is this web service that i need to consume from a C# client on an aspx page I want to develop, but first I need to understand the webservice, I'm not sure which language it's made upon but I think it's PERL, since the web service's URL is like this "http://wschsol.mideplan.cl/mod_perl/xml/fps-by-rut". This webservice was developed by other people which i cannot contact right now and is running on a linux server to which i don't have access either.

web服务的工作是pretty简单,它接受一个人的身份证号码,并返回关于他的一些XML格式的信息,我想显示一些电网和东西我的客户aspx页面上。

The webservice's job is pretty simple, it receives a person's national ID number and returns some information about him on xml format, which i want to show on my client aspx page with some grids and stuff.

我看过周围,它可能看到一个web服务的描述,它的方法使用后常见的的.asmx为扩展名的WSDL变量互联网,但在这种情况下,没有扩展,因此,我不能使用的?WSDL。我猜,也许fps_by​​_rut只是一个WebMethod,而不是web服务本身。所以,问题是:我怎么使用web服务?
因为我知道那种请求所期望的(一个人的ID),我试图通过浏览器的ID手动添加到URL(这样的:的 http://wschsol.mideplan.cl/mod_perl/xml/fps-by-rut?rut=6985462-1 ),如果我做它在XML格式的正常反应。

I have read around the internet that it's possible to see a description of a webservice and its methods using the WSDL variable after the common ".asmx" extension, but in this case there is no extension and so, i can't use the the ?WSDL. I'm guessing that maybe "fps_by_rut" is only a webmethod, and not the webservice itself. So the question is: how do I use the webservice? Since I know what kind of request is expected (a person's ID), I tried to manually add an ID to the URL through the browser (like this: "http://wschsol.mideplan.cl/mod_perl/xml/fps-by-rut?rut=6985462-1") and if I do it responds normally in xml format.

我想它在我的项目添加Web服务引用,但远,我粘贴整个URL,当我点击走出去它说,它需要的凭据。我有这些证书,一个用户名和密码,但他们没有工作...有什么困惑我的是,还有另外一个客户端程序就在这里我面前的家伙做传统的ASP同样的web服务,我可以存取权限的code,当我看到他调用Web服务是这样的线路:

I tried to add a web service reference for it on my project, but well, i pasted the whole URL and when I click "go" it says it needs credentials. I have these credentials, a user and password, but they are not working... what confuses me is that there is another client to this same webservice programmed on classic asp made by the guy before me here, and i can acces that code, and when i see the line on which he calls the web service it's like this:

xml.Open "GET", "http://wschsol.mideplan.cl/mod_perl/xml/fps-by-rut?rut="&rsVac(0), False,"user","password"

我已经删了用户和密码的字符串,因为这些都是实际的凭据。这款经典的ASP客户工作正常使用这些凭据。我试图创建引用时使用的,但他们没有工作。更有甚者,当我手工通过浏览器添加了ID它要求我提供凭据和他们的工作太...

i have censored the "user" and "password" strings since those are the actual credentials. This classic asp client works fine with those credentials. I tried to use those when creating the reference, but they are not working. Even more, when i manually added the ID through the browser it asked me for credentials and they worked too...

我是不是走错路了?请大家好,我需要指导。如果有一门课程在那里,我可以读,可以帮助我理解这一切的WebServices的东西,我会非常感激。或者,如果有人能告诉我该走哪条路,我是pretty肯定,我在错误的方向...

Am I going the wrong way? Please guys, i need guidance. If there is a course out there which I can read that helps me understand all of this webservices stuff, i'd be hugely grateful. Or if someone can tell me which way to go, I'm pretty sure I'm in the wrong direction...

在此先感谢您的帮助!

推荐答案

WSDL用于SOAP和我们俩不知道,如果它是一个SOAP的服务。结果
你应该只使用一个的HttpClient 键,让你获取通话的API。结果
您可以使用这样的:

WSDL is used for SOAP and we both don't know if it's an SOAP-Service.
You should just use a HttpClient and make your Get-Calls to the API.
You can use something like this:

var client = new HttpClient();
client.BaseAddress = new Uri("http://wschsol.mideplan.cl");
var httpResponse = await client.GetStringAsync("mod_perl/xml/fps-by-rut?rut=<InsertParamHere>");

编辑授权:结果
你必须补充一点:

Edit Authorization:
You have to add this:

var byteArray = Encoding.ASCII.GetBytes("username:password1234");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));

片段来源:的简单的C#.NET 4.5请求了HTTPClient使用基本身份验证和代理

这篇关于未知WebService的描述和从C#使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆