开发者

Consuming web services in VB.NET

开发者 https://www.devze.com 2022-12-20 21:14 出处:网络
I am testing web services in .NET for the first time. I am almost there, but I can\'t seem to consume the web service. I know this post is similar to about 5-6 other posts on this site, but I have rev

I am testing web services in .NET for the first time. I am almost there, but I can't seem to consume the web service. I know this post is similar to about 5-6 other posts on this site, but I have reviewed them, and still can't get the syntax correct.

So far, I have: -Create a simple web service that creates a directory -Worked in development environment, but took some trouble shooting to get to work on live server -I can pull up the "automagically" generated .NET we service page. -Added web service reference - can now see the reference in my solution explorer and in intellisense.

Update: Here is a link to the webservice itself: http://67.78.188.50/Jservices/Service1.asmx

The web service accepts a string (name of directory e.g /test/directory). However, when I enter the name of the Web Reference (ServiceReference1) - I don't get the methods I expect...

Here are my options with the ServiceReference1 Object...

ServiceReference1.m开发者_如何学CakeDirRequest
ServiceReference1.makeDirRequestBody
ServiceReference1.makeDirResponse
ServiceReference1.makeDirResponseBody
ServiceReference1.Service1Soap
ServiceReference1.Service1SoapChannel
ServiceReference1.Service1SoapClient


Pass, you haven't posted enough code to see what you have done

I would strongly recommend that your use WCF

Given your sample names proved, you need

Dim service As New ServiceReference1.Service1SoapClient
service.makeDir("some val")

Download one of the many samples on the web (plenty on codeproject) and get the sample working first. If you cant get that to go then something else is wrong with you Windows installation


I'm not sure that makeDirRequest is the service - that sounds like a message. Look for another type in that namespace (maybe ending in "service" or "client" if you are lucky, but ultimately named based on what you typed when using "add web reference" etc), that inherits from WebService.

This should have your service method(s) as public methods.


Having seen the service, I expect the problem is that you are adding a service-reference (WCF / 3.0) rather than a web-reference (2.0). If you are targetting 3.0 / 3.5, you can add a web-reference by using the "Advanced..." => "Add Web Reference" option (in the "Add Service Reference" dialog). Then you can use (where WebReference is whatever you named it when adding the reference):

Using client As WebReference.Service1 = New WebReference.Service1
    Dim foo As String = "foo"
    client.makeDir(foo)
End Using

If you instead use a WCF service-reference, then the name tends to include the "Soap" overhead (where ServiceReference1 is whatever you named it when adding the reference):

Using client As ServiceReference1.Service1SoapClient = New ServiceReference1.Service1SoapClient
    Dim foo As String = "foo"
    client.makeDir(foo)
End Using

Either way, it should work the same.


Consume a Web service in a .NET app

http://articles.techrepublic.com/5100-10878_11-5768122.html

Creating and Consuming Web Services - OS, Software & Networking by ...

http://www.extremetech.com/article2/0,2845,11511,00.asp

Consuming Web Services from a Win Forms Application - CodeProject

http://www.codeproject.com/KB/webservices/cpwebserviceconsumer.aspx


See How to Consume a Web Service and see if it helps you. The example is in C#, but you should find it easy to translate.

0

精彩评论

暂无评论...
验证码 换一张
取 消