2

Our machine has multiple IP addresses and server only accepts requests from one specific IP address. I'm looking for a way to send SOAP request from a specific IP address.

This question is an extension to this one but it was for Web References, I'm using a Service Reference.

I am using Visual Studio 2013. It generated proxy classes from WSDL and it looks like it uses WCF / ServiceModel to send the requests.

The generated proxy class for the client looks like this:

<System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")> _
Partial Public Class TestActivitySoapClient
    Inherits System.ServiceModel.ClientBase(Of Consoto.TestActivitySoap)
    Implements Consoto.TestActivitySoap

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String)
        MyBase.New(endpointConfigurationName)
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
        MyBase.New(endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(endpointConfigurationName, remoteAddress)
    End Sub

    Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
        MyBase.New(binding, remoteAddress)
    End Sub

    <System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)> _
    Function Consoto_TestActivitySoap_TestActivity(ByVal request As Consoto.TestActivityRequest) As Consoto.TestActivityServiceResponse Implements Consoto.TestActivitySoap.TestActivity
        Return MyBase.Channel.TestActivity(request)
    End Function

    Public Function TestActivity(ByVal TestActivity1 As Consoto.TestActivity) As Consoto.TestActivityResponse
        Dim inValue As Consoto.TestActivityRequest = New Consoto.TestActivityRequest()
        inValue.TestActivity = TestActivity1
        Dim retVal As Consoto.TestActivityServiceResponse = CType(Me, Consoto.TestActivitySoap).TestActivity(inValue)
        Return retVal.TestActivityResponse
    End Function

    <System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)> _
    Function Consoto_TestActivitySoap_TestActivityAsync(ByVal request As Consoto.TestActivityRequest) As System.Threading.Tasks.Task(Of Consoto.TestActivityServiceResponse) Implements Consoto.TestActivitySoap.TestActivityAsync
        Return MyBase.Channel.TestActivityAsync(request)
    End Function

    Public Function TestActivityAsync(ByVal TestActivity As Consoto.TestActivity) As System.Threading.Tasks.Task(Of Consoto.TestActivityServiceResponse)
        Dim inValue As Consoto.TestActivityRequest = New Consoto.TestActivityRequest()
        inValue.TestActivity = TestActivity
        Return CType(Me, Consoto.TestActivitySoap).TestActivityAsync(inValue)
    End Function 
End Class

I tried to override CreateChannel

Protected Overrides Function CreateChannel() As TestActivitySoap
    Return MyBase.CreateChannel()
End Function

but couldn't figure out what should I write.

Moreover, I couldn't find a way to override the behaviour of System.ServiceModel.ClientBase to specify a local EndPoint and I'm open to all suggestions in any .NET language. If this is not possible, please suggest an alternative method to achieve this.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.