WCF无法找到默认端点

时间:2010-09-10 12:25:14

标签: wcf web-services

我正在使用对webservice的服务引用并创建了它的新实例。我创建了一条消息,并尝试将其发送到Web服务,但我收到此错误:

  

无法找到默认端点   引用合同的元素   'receivePortService.ITwoWayAsyncVoid'   在ServiceModel客户端中   配置部分。这可能是   因为没有配置文件   找到您的申请,或因为   没有匹配此的端点元素   合同可以在客户端找到   元件。

现在我正在将此应用程序部署到sharepoint,所以我只有dll文件。有没有办法可以在代码中手动设置配置文件中的属性?

receivePortService.TwoWayAsyncVoidClient client = new TaskCompletedHandler.receivePortService.TwoWayAsyncVoidClient();
Message msg = Message.CreateMessage(MessageVersion.Default,"*",XmlTextReader.Create(xmlMessage));
client.BizTalkSubmit(msg);

如何在没有app.config的情况下设置endpointaddress和stuff?

1 个答案:

答案 0 :(得分:0)

通常,您的TwoWayAsyncVoidClient类应该有多个重载构造函数 - 尤其应该使用BindingEndpointAddress作为参数。

所以在代码中,你可以创建例如。

WSDualHttpBinding myBinding = new WSDualHttpBinding();
EndpointAddress epa = new EndpointAddress(new Uri("http://yourserver:7777/YourService/TheService.svc"));

receivePortService.TwoWayAsyncVoidClient client = new TaskCompletedHandler.receivePortService.TwoWayAsyncVoidClient(myBinding, epa);

WSDualHttpBinding是双/双向绑定(我假设您要使用,基于您的客户端类的名称),您可能还需要设置其他内容,如回调合同接口和回调地址 - 但是这个代码至少应该让你开始,我希望!

相关问题