tags:

views:

379

answers:

3

Has anyone done this? I've tried generating a c# proxy class and connecting through it, but I cannot figure out how to get IronPython to use the generated app.config file that defines the endpoint. It tries to connect, but I just get an error about no default endpoint. I would ideally like to make the connection using only IronPython code and not use the proxy class, if possible. The binding for the service I am trying to connect to is a NetTcpBinding if that makes any difference.

A: 

Is your WCF service interface available in a shared assembly? If so, you could look at using the ChannelFactory to create your client proxy dynamically (instead of using the generated C# proxy). With that method you can supply all the details of the endpoint when you create the ChannelFactory and you won't require any configuration in your .config file.

Jeremy Wiebe
Any idea how to do that in IronPython? I've tried that approach and it doesn't seem to work. I got an error about some IronPython class not supporting reflection.
jhale
Sorry, that I don't know. I've never used IronPython. That might be a good question for the CodePlex discussion forums for IronPython.
Jeremy Wiebe
A: 

One way to communicate with a WCF service using Ironpython is:

  • Configure your WCF service to have a basichttpbinding
  • Communicate with the WCF service using SOAP as if it was a standard web service

For an example of using python with SOAP see:

http://diveintopython.org/soap%5Fweb%5Fservices/index.html

This is probably not exactly what you were looking for, you loose the benefit of NetTcpBinding. This may become easier when VS2010 is released.

Shiraz Bhaiji
A: 

See my blog post. There are IronPython WCF service and client examples.

To use app.config, you probably must copy it to ipy.exe and rename it to ipy.exe.config but I have not tried it so I don't know whether it works or not.

Lukas Cenovsky