WCF 访问Webservice 生成接口文件

来源:互联网 发布:java前n字符排序 编辑:程序博客网 时间:2024/05/19 08:45

第一步:生成接口

C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin>svcutil http://localhost:52141/BasicCalculator.asmx /out:d:\abc

 

第二步:调用

PrimaryServiceSoap proxy = ChannelFactory<PrimaryServiceSoap>.CreateChannel(
      new BasicHttpBinding(), new EndpointAddress(MBCommon.SessionManage.ROUTERURL));//路由地址

    using (OperationContextScope scope = new OperationContextScope((IContextChannel)proxy))
    {
     MessageHeader mgh = MessageHeader.CreateHeader("业务功能", "http://company.ESB.FN/", "业务系统.获取信息");//服务标识
     OperationContext.Current.OutgoingMessageHeaders.Add(mgh);
     GetGeneral3Request request = new GetGeneral3Request(new GetGeneral3RequestBody(strUserCert));
     GetGeneral3Response result = proxy.GetGeneral3(request);//webserver上的函数

    }

原创粉丝点击