从特定IP地址发送SOAP请求 [英] Send SOAP Request from a specific IP address

查看:169
本文介绍了从特定IP地址发送SOAP请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统具有多个IP地址.但是允许我仅从一个IP地址发起SOAP请求.如何在VB.NET中获取它.

I have a system with multiple IP address. But I'm allowed to initiate SOAP Request only from one IP address. How do I obtain that in VB.NET.

推荐答案

我从未做到过.看起来很复杂.

I've never done this. It looks complicated.

首先,阅读方法自定义ASMX客户端代理,以了解覆盖代理类的GetWebRequest对象的基本技术.

First, read Ways to Customize your ASMX Client Proxy to learn the basic technique of overriding the GetWebRequest object of your proxy class.

您将需要覆盖GetWebRequest,以便可以获取用于进行请求的ServicePoint.您将 BindIPEndPoint 属性设置为委托指向您将返回正确IP地址的方法.

You will need to override GetWebRequest so that you can grab the ServicePoint being used to make the request. You will set the BindIPEndPoint property to a delegate pointing to a method of yours which will return the correct IP Address.

public partial class Service1
{
    protected override WebRequest GetWebRequest(Uri uri)
    {
        HttpWebRequest request = (HttpWebRequest) base.GetWebRequest(uri);
        request.ServicePoint.BindIPEndPointDelegate = ReturnSpecificIPAddress;
        return request;
    }

    private IPEndPoint BindIPEndPoint(
        ServicePoint servicePoint,
        IPEndPoint remoteEndPoint,
        int retryCount)
    {
        return new IPEndPoint(IPAddress.Parse("10.0.0.1"), 80);
    }
}

这篇关于从特定IP地址发送SOAP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆