How to add a web service reference in a DLL

后端 未结 5 1078
走了就别回头了
走了就别回头了 2021-01-03 00:07

I\'m creating a DLL with a reference to web services (I don\'t have the choice to do so) but I have to add web service references to the project that uses the DLL for it to

5条回答
  •  一个人的身影
    2021-01-03 00:36

    right-click Add Service Reference in your client's project for add Methods and Classes

    Then To access the service you can then do something like in dll

    EndpointIdentity spn = EndpointIdentity.CreateSpnIdentity("host/mikev-ws");
    Uri uri = new Uri("http://example.com/test.asmx");
    var address = new EndpointAddress(uri, spn);
    BasicHttpBinding basic = new BasicHttpBinding();
    basic.Name = "bindingName";
    
    var client = new MyService.MyWebServiceSoapClient(basic, address);
    client.HelloWorld();
    

提交回复
热议问题