SOAP Client in C# without access to a WSDL-file

前端 未结 4 1795
北荒
北荒 2021-02-02 17:17

I\'m working with a third party to integrate some of our systems with theirs and they provide us with a SOAP interface to make certain requests and changes in their connected sy

4条回答
  •  春和景丽
    2021-02-02 18:15

    the code here is in VB.NET but I think you'll get the idea. The following is a client that invokes the 'processConfirmation' method and it expects a response (MyBase.SendRequestResponse).

    Imports Microsoft.Web.Services3
    Imports Microsoft.Web.Services3.Addressing
    Imports Microsoft.Web.Services3.Messaging
    
    Namespace Logic
        Public Class HTTPClient
            Inherits Soapclient
    
            Sub New(ByVal destination As EndpointReference)
                MyBase.Destination = destination
            End Sub
    
             _
            Public Function processConfirmation(ByVal envelope As SoapEnvelope) As SoapEnvelope
                Return MyBase.SendRequestResponse("processConfirmation", envelope)
            End Function
        End Class
    End Namespace
    

    And you use it by doing the following:

    Dim hc As New HTTPClient(New Microsoft.Web.Services3.Addressing.EndpointReference(New System.Uri("http://whatever.srv")))
    
    Dim envelope As New Microsoft.Web.Services3.SoapEnvelope
    Dim doc As New Xml.XmlDocument
    doc.LoadXml("there")
    envelope.SetBodyObject(doc)
    
    Dim return_envelope As Microsoft.Web.Services3.SoapEnvelope = hc.processConfirmation(envelope)
    

    I think this should work .... success!

提交回复
热议问题