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?
You get WCF to work with InfoPath by using basicHttpBinding instead of wsHttpBinding in webconfig.
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>
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.
Related
I have an IIS hosted WCF service that I need to expose to two client types, external (basicHttp legacy) and internal (wsHttp WCF). For the external client I want to impose a more strict throttling configuration. It seems that the throttling config such as:
<serviceThrottling
maxConcurrentCalls="30"
maxConcurrentSessions="1000"
maxConcurrentInstances="30" />
can only be applied as a service behavior and not as an endpoint behavior. This means that I'll need to create two separate .svc files, which would resolve to the same .cs file, such as follows:
<service behaviorConfiguration="x.xServiceBehavior">
<endpoint
address="~/xService.svc"
binding="wsHttpBinding"
contract="xService.IxService"/>
</service>
<service behaviorConfiguration="xService.ThrottledxServiceBehavior">
<endpoint
address="~/ThrottledxService.svc"
binding="basicHttpBinding"
contract="x.xService.IxService"/>
</service>
Is that the best way to achieve what I'm after or is there an better way?
Thanks
Rob.
The way you have done it looks correct to achieve a different service behaviorConfiguration for the two different bindings. It may be possible to achieve the same effect while avoiding having two .svc files, but the way above will work fine so why rock the boat! :)
I'm just learning wcf and can't understand one very basic thing.
I'm creating a WCF service which I want to be hosted in IIS just like web application with it's own path like http://myhost/myapp/ and everything.
I'm creating the WCF service project in VS, I've got an *.svc file describing it, then I define a simple endpoint to it like that:
<endpoint address=""
binding="basicHttpBinding"
contract="wcf_service_auth.IPshService" />
Then I publish this service like an IIS web application to a virtual directory, let's assume it's name psh_pub, so I can access the service via url http://localhost/psh_pub/pshservice.svc/. It shows me WCF greetings page and gives me a link to WSDL, which gives me correct wsdl description.
That's ok.
The next step - I want to add a MEX endpoint. I add to config:
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
That's ok too, the endpoint is accessible at address http://localhost/psh_pub/pshservice.svc/mex and WcfTestClient.exe gives me correct config from that url.
Here the problem comes.
I have a WCF service working under IIS and I want to add one more endpoint to it. For example let it be a net.tcp endpoint. The IIS is configured by default to accept net.tcp connections at port 808 and I'm adding net.tcp protocol to properties of my web app, and I want to add an endpoint to my service like that:
<endpoint address=""
binding="netTcpBinding"
contract="wcf_service_auth.IPshService" />
and now I assume that my service should be accessible via the url net.tcp://localhost:808/psh_pub/pshservice.svc. But it's not. And every "how-to" and manual on the web tells that I should specify full address in the config file like that:
<endpoint address="net.tcp://localhost:808/psh_pub/pshservice.svc"
binding="netTcpBinding"
contract="wcf_service_auth.IPshService" />
And if I do so, it works. But if host the service in another virtual directory, I'll need to change the config. If I host it on the other server, I'll need to change config. If I host it on multiple servers, I'll have to maintain as many configs as servers I have.
So the main questions is:
Is there any way in WCF to specify a net.tcp (or https) endpoint of a IIS-hosted WCF service without specifying absolute url for it?
You should be able to define a base address for your net.tcp service endpoints:
<service name="YourServiceName">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:808/psh_pub/" />
</baseAddresses>
</host>
Then you should be able to use relative addresses in your actual endpoints:
<endpoint name="Tcp01"
address="pshservice.svc"
binding="netTcpBinding"
contract="wcf_service_auth.IPshService" />
</service>
WCF file-less activation (.Net 4.0) will let you register under a relative virtual path using the relativeAddress attribute:
<system.serviceModel>
<serviceHostingEnvironment>
<serviceActivations>
<add relativeAddress="relative-virtual-path/yourservice.svc"
service="YourServiceImpl" />
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
relative to the base address of the Web application
This link talks about it: http://msdn.microsoft.com/en-us/library/ee354381.aspx
I'm just trying to save time by not learning about IIS and WAS, so I made a console application to host my WCF service. However, that leaves me uncertain as to how to specify an endpoint address that is not an HTTP address. Could the following config be the source of my runtime error? The exception description was: Could not find a base address that matches scheme http for the endpoint with binding WSHttpBinding. Registered base address schemes are [].
<system.serviceModel>
<services>
<service name="WcfService1.Service1">
<endpoint
contract="WcfService1.IService1"
binding="wsHttpBinding"
address="c:\users\owner\documents\visual studio 2010\projects\wcftest\wcfservice1\wcfservice1\service1.svc"/endpoint>
</service>
</services>
The word you're looking for is bindings. You change the binding attribute to match a binding that supports your desired protocol. For a simple console service host, I'd probably start with the netTcpBinding, which allows binding to an ipaddress:port combination.
Example:
net.tcp://localhost:8000/myservice
When I deployed my WCF Data Services to production hosting I started to get the following error (or similar depending on which auth schemes are active):
IIS specified authentication schemes
'Basic, Anonymous', but the binding
only supports specification of exactly
one authentication scheme. Valid
authentication schemes are Digest,
Negotiate, NTLM, Basic, or Anonymous.
Change the IIS settings so that only a
single authentication scheme is used.
Apparently WCF Data Services (WCF in general?) cannot handle having more than once authentication scheme active.
OK so I am aware that I can disable all-but-one authentication scheme on the web application via IIS control panel .... via a support request!!
Is there a way to specify a single authentication scheme on a per-service level in the web.config?
I thought this might be as straight forward as making a change to <system.serviceModel> but... it turns out that WCF Data Services do not configure themselves in the web config. If you look at the DataService<> class it does not implement a [ServiceContract] hence you cannot refer to it in the <service><endpoint>...which I presume would be needed for changing its configuration via XML.
P.S. Our host is using II6, but both solutions for IIS6 & IIS7 appreciated.
Firstly it is possible to configurate Data Services on the web config file. The contract used by the DataService is called System.Data.Services.IRequestHandler.
Here is what you can do in the web config file to configurate it.
On the Service tag of the system.servicemodel element add the
<service name="{you service type name including the namespace i.e. myapplication.myservice}">
<endpoint address="" binding="webHttpBinding" contract="System.Data.Services.IRequestHandler">
</endpoint>
</service>
Once you have that there you can start configuring all manners of thing using the standard WCF configuration elements.
Secondly to enable or disabled authentication methods for a specific service in IIS you can do the following:
On the snap in for IIS right click your service file (i.e. yourservice.svc) and click properties.
Once in properties go to File Security Tab and chose the Edit button on the authentication and access control group box. after that it is just like setting up directory security in IIS.
As a last suggestion as per any trouble shooting goes it is important to enable the wcf disgnostics while you configurate it using the xml configuration, being written in WCF, Data Service logging is as per wcf is rich and very informative.
you can find out more about that on WCF Administration and Diagnostics
I hope i was able to help you with your problem
let me know how things goes.
Regards
Daniel Portella
UPDATE:
Hi Schneider
To specify the authentication scheme in the xml read below
For windows authentication as a example
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="MyBindingName" >
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="{you service type name including the namespace i.e. myapplication.myservice}">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="MyBindingName" contract="System.Data.Services.IRequestHandler">
</endpoint>
</service>
</services>
</system.serviceModel>
</configuration>
For other types of authentication please check the MSDN library for examples
Common Scenarios for security
Is it possible to have a WCF service configuration like this:
<service behaviorConfiguration="WcfService1.Service1Behavior"
name="WcfService1.Service1">
<endpoint address="" binding="netTcpBinding" bindingConfiguration=""
contract="WcfService1.IService1">
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost/netTcpService" />
</baseAddresses>
</host>
</service>
And have it hosted on the ASP.NET development server that comes with Visual Studio 2008, or do I necessarily have to host the service in IIS 7 or self-host it in a managed application/Windows service?
Thank you for your insights!
IIS6 and the built-in Cassini web server both support only http, sorry.
You'll have to either self-host your service in e.g. a console app, or host it in IIS7 in order to use NetTCP.
VS2008 SP1 also comes with a WCF Test Host app that can be used for those purposes, and it supports NetTCP and all other protocols as well.
It's called WcfSvcHost.exe and should be found in your C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE directory. You can specify a DLL containing your service implementation and a config file for it, and it'll load your service and host it for you.
MSDN documentation for the WcfSvcHost is here:
http://msdn.microsoft.com/en-us/library/bb552363.aspx
Here's what it'll look like in your environment:
and here's the WcfTestClient.exe connected to that hosted service - note the netTcp endpoint:
To set it up in Visual Studio, use the WCF service library project's "Properties" tab and pick to launch WcfSvcHost.exe as the external program and supply the correct command-line arguments like this:
Now if you press F5 to run the class library containing your WCF service, it'll launch the test host and host your service library in there, ready to be tested.
Marc