我正在尝试使用此锅炉板方法中的WSDL文件的服务引用来配置脚本组件。
public override void CreateNewOutputRows()
{
//create instance of service client
}
但是我遇到配置文件app.config的问题,该文件抱怨合同属性无效contract="ServiceReference1.IClientService1
所有手动更改此操作的尝试都失败了。类似的帖子建议使用完全限定名称Service.MyService,但到目前为止我没有任何成功。有没有办法以编程方式指定绑定?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IClientService1">
<security mode="Transport" />
</binding>
<binding name="BasicHttpBinding_IClientService11" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://server/services/ClientService1.svc/soap"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IClientService1"
contract="ServiceReference1.IClientService1" name="BasicHttpBinding_IClientService1" />
</client>
</system.serviceModel>
</configuration>
存根代码如下所示
public override void CreateNewOutputRows()
{
string endpoint = "https://server/services/ClientService1.svc";
ClientService1Client client = new ClientService1Client(endpoint);
client.ClientCredentials.UserName.UserName = "";
client.ClientCredentials.UserName.Password = "";
Output0Buffer.name = client.GetActiveClients()[1].name.ToString();
}
答案 0 :(得分:2)
我认为您的问题可能是由于您的端点地址中有/soap
<endpoint address="https://server/services/ClientService1.svc/soap"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IClientService1"
contract="ServiceReference1.IClientService1" name="BasicHttpBinding_IClientService1" />
我认为应该只是:
address="https://server/services/ClientService1.svc"
至于以编程方式创建绑定,这应该起作用或让你开始:
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
EndpointAddress address = new EndpointAddress("https://server/services/ClientService1.svc");
ClientService1Client client = new ClientService1Client(binding, address);