- 所属分类:网站建设知识
- 作者: 独占网络
- 更新时间: 2015-2-22 13:17:45
- 返回列表
我们经常通过.net的webserver去调用其它项目的webserver来实现交换信息,但是如果我们交换信息的方法是采用java的soap写的方法,而且这个方法还有加密的方法,那我们需要怎样调用吧,下面我们先来书写一个.net的类,这个类是用于我们传递参数的。
由于代码大多我们就只贴出部分的代码
public ClientInspector ClientInspector { get; set; }
public InspectorBehavior(ClientInspector clientInspector)
{
ClientInspector = clientInspector;
}
public InspectorBehavior()
{
}
public void Validate(ServiceEndpoint endpoint)
{ }
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{ }
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
if (this.ClientInspector == null) throw new InvalidOperationException("Caller must supply ClientInspector.");
clientRuntime.MessageInspectors.Add(ClientInspector);
}
}
其它我们这解决方法里面重要的方法还是我们下面的方法。
ProductWebServiceClient productclient = new ProductWebServiceClient();
productclient.Endpoint.Behaviors.Add(new InspectorBehavior(new ClientInspector(new SecurityHeader("duzhan", "sz886"))));
通过我们上面的代码我们可以看出,我们这里面重要的方法还是使用new SecurityHeader("duzhan", "sz886")方法将我们用户名还有密码传递过去给到用户引用。
如有不懂,联系独占网络(http://www.sz886.com)