如何使用VB.Net在Asp.net中使用非.net Web服务 [英] How to consume Non .net Web Service in Asp.net using VB.Net

查看:71
本文介绍了如何使用VB.Net在Asp.net中使用非.net Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的客户端为我们提供了带有UserName和password.Im的Web服务URI。试图通过代码隐藏使用VB.Net来使用Asp.net中的非.Net Web服务。我的代码是 -

Hi All,
My Client has provide us with the Web Service URl with UserName and password.Im Trying to consume Non .Net Web service in Asp.net using VB.Net through code behind . My code is -

Dim request As HttpWebRequest
Dim response As HttpWebResponse = Nothing
Dim reader As StreamReader

Try

    request = HttpWebRequest.Create("https://webserviceurl")
     request.Method ="POST";
    request.Timeout = 15 * 10000
    request.Credentials = New NetworkCredential("UserName","Password")
    request.ContentLength = 0
    response = DirectCast(request.GetResponse(), HttpWebResponse)
    reader = New StreamReader(response.GetResponseStream())
    Console.WriteLine(reader.ReadToEnd())
Finally
    If Not response Is Nothing Then response.Close()
End Try





但我得到的错误号码:500



请指导我解决这个问题。



提前致谢。



But Iam getting the error Number: 500

Please kindly guide me to resolve this issue.

Thanks in advance.

推荐答案

由于您有WSDL(感谢您回答我的问题),除了服务本身之外,这就是您所需要的。请参阅:

http://en.wikipedia.org/wiki/WSDL [< a href =http://en.wikipedia.org/wiki/WSDLtarget =_ blanktitle =New Window> ^ ]。



基本上,您使用wsdl.exe实用程序为服务创建存根: http://msdn.microsoft.com/en-us/library/7h3ystb6%28v=vs.100%29.aspx [ ^ ]。



你创建一个生成的存根并在你的项目中使用它。



这是一个简短的演练手册:http://www.sitepoint.com/net-web-services-5-steps-2/ [<一个href =http://www.sitepoint.com/net-web-services-5-steps-2/target =_ blanktitle =新窗口> ^ ]。



您可以找到许多其他样品或说明o在网上的步骤,请参阅: http://bit.ly/1hvDidt [ ^ ]。



-SA
As you have WSDL (thank you for answering my question), this is all what you need, in addition to the service itself. Please see:
http://en.wikipedia.org/wiki/WSDL[^].

Basically, you create a stub for the service using the "wsdl.exe" utility: http://msdn.microsoft.com/en-us/library/7h3ystb6%28v=vs.100%29.aspx[^].

You create a stub generated and use it in your project.

Here is the short walk-through manual: http://www.sitepoint.com/net-web-services-5-steps-2/[^].

You can find many other samples or descriptions of the steps on the Web, please see: http://bit.ly/1hvDidt[^].

—SA


从Web服务返回的数据应该是JSON格式。因为几乎所有支持数据传输的语言都支持JSON。

然后您可以轻松使用跨语言Web服务。
The data return from the web service should be in the JSON Format. Because almost all language which are support data transmission are supporting the JSON.
Then you can easily consume the cross language web service .


这篇关于如何使用VB.Net在Asp.net中使用非.net Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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