Consuming web services in VB.NET

后端 未结 4 350
感情败类
感情败类 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:00

    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 讨论(0)
  • 2021-01-13 02:04

    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

    0 讨论(0)
  • 2021-01-13 02:12

    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

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题