tags:

views:

348

answers:

3

I am having trouble trying to connect an Infopath 2007 form to an WCF web service. I appears that the Infopath only wants to communicate via a SOAP 1.0 message. To get around the issue for the moment I have created an .asmx web service. Should I consider continuing down this workaround or figure out a way to get WCF to dish out SOAP 1.0 1.1 messages?

+2  A: 

You get WCF to work with InfoPath by using basicHttpBinding instead of wsHttpBinding in webconfig.

xanax
A: 

Just to help with the answer by xanax this is what I ended up doing in the web.config file. this is a part of the default config that gets generated when you create a new WCF service. I commented out the one endpoint and added a new one with the only change being the binding from wsHttpBinding to basicHttpBinding and it worked.

    <system.serviceModel>
         <services>
          <service name="Service" behaviorConfiguration="ServiceBehavior">
           <!-- Service Endpoints -->
           <!--<endpoint address="" binding="wsHttpBinding" contract="IService">-->
           <endpoint address="" binding="basicHttpBinding" contract="IService">
            <identity>
             <dns value="localhost"/>
            </identity>
           </endpoint>
           <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
         </services>
...Other Config Here....
    <system.serviceModel>
Nathan Fisher
A: 

InfoPath by default works only with basicHttpBinding. When using webservice with InfoPath, typically the webservice URL is put in a UDX file. In that file, there is no way to specify a binding for the target service. You do not typically create a proxy for your service yourself, InfoPath does it for you behind the scene and that proxy only uses basicHttpBinding.

If you want your InfoPath forms to work with a WCF service which uses a non basicHttpBinding, you can do so by creating a proxy yourself programmatically in your InfoPath form code. When you are creating the proxy programmatically you can specify your target WCF service's binding in proxy's constructor. No limitation exists when you use the programatically created proxy. Of course, .NET 3.5 should already have been installed so that WCF libraries are available to your code to create those proxies with right bindings. When you install InfoPath, only .NET 2 is available.

I have tried this with wsHttpBinding and it worked without a problem. From reading many articles and posts, it appears many people believe InfoPath can only work with basicHttpBinding. That is only partially true, because it applies only when you do not create your proxies yourself.

Roshan
agreed. I was originally trying to get WCF to work with infopath without the form code. in the end I just went with the old asmx webservices. just less hassle to let infopath sort out its proxies especially when the interface was changing. and less hassle on the webservice side as it just worked with infopath, no workarounds.I will probably look at this further down the track.
Nathan Fisher