views:

17

answers:

1

Hi all,

I am using a service reference to a webservice and created a new instance of it. I created a message and tried to send this to the webservice but I get this error:

Could not find default endpoint element that references contract 'receivePortService.ITwoWayAsyncVoid' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

Now I am deploying this application to sharepoint, so I just have the dll file. Is there way I can manually set the properties from the configuration file in code?

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

How can I set the endpointaddress and stuff without the app.config?

A: 

Typically, your TwoWayAsyncVoidClient class should have several overloaded constructor - one in particular should take a Binding and an EndpointAddress as its parameters.

So in code, you could create e.g.

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);

With WSDualHttpBinding being a dual / two-way binding (which I'm assuming you want to use, based on the name of your client class), you might also need to set additional stuff like the callback contract interface and callback address - but that code should at least get you started, I hope!

marc_s