Consuming web services in VB.NET

后端 未结 4 354
感情败类
感情败类 2021-01-13 01:47

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 o

4条回答
  •  时光说笑
    2021-01-13 02:19

    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.

提交回复
热议问题