I am making WFC service. When I debug it from Visual Studio all is ok, but I've faced with problem when I deploy it on real IIS.
After deploying I still can get WSDL but when I request WebGet method (which returns a simple XML document) method I got the following error:
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
What can be cause of problem?
My Web.Config:
<system.serviceModel>
<services>
<service name="XXXX.TSDX.UI.TsdxService">
<endpoint
address="Tsdx"
binding="webHttpBinding"
bindingConfiguration="TestBinding"
behaviorConfiguration="RESTFriendly"
contract="XXXX.TSDX.UI.ITsdxService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="TestBinding" />
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="RESTFriendly">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Verify that the correct version of the .NET framework selected in the ASP.NET tab (in IIS) for your application
If you are hosting this service in MVC app please make sure to add below line to ignore controller routing conflict, I had this issue after struggling for sometime I found this answer which has resolved the issue.
routes.IgnoreRoute("{allsvc}", new { allsvc = #"..svc(/.*)?" });
Related
This question already exists:
support about Web service when hosting in IIS
Closed 9 years ago.
I writing a Web service, when I run it in localhost, everything is OK, but I host in IIS 7.0 , it's not running. Please support me!!!
Here my Web.config
<system.serviceModel>
<services>
<service name="VivuFace_V2.api.CloudCameraService" behaviorConfiguration="VivuFace_V2.api.CloudCameraServiceBehavior">
<endpoint address="../CloudCameraService.svc"
binding="webHttpBinding"
contract="VivuFace_V2.api.ICloudCameraService"
behaviorConfiguration="webBehaviour" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VivuFace_V2.api.CloudCameraServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
This is very open ended since there is no error message here, but my experience is that a lot of the time issues related to hosting under IIS is due to the following:
Make sure your app pool is configured for the right version of Net
Make sure asp.net support is installed in IIS
Make sure permissions are configured correctly
I think it may be due to not having/requiring any base address to be specified in the config. Everything else works fine, including publishing WSDL, calling the service, etc. but when I add a MEX endpoint and try to access it, it returns 503 service unavailable.
My web.config looks like this:
<system.serviceModel>
<bindings>
<basicHttpsBinding>
<binding name="ServiceBinding" />
</basicHttpsBinding>
</bindings>
<services>
<service name="MyServices.CatService" behaviorConfiguration="MyBehavior">
<endpoint address="" binding="basicHttpsBinding" bindingConfiguration="ServiceBinding" contract="MyServices.ICatService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
When I browse to my service, I get the message:
You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from
the command line with the following syntax:
svcutil.exe http://[mypc]/MyServices/CatService.svc/mex
I'm reasonably sure it's to do with the way the endpoints are defined, but I don't know how to fix it. Any ideas?
Solved - the mex example above that I copied and pasted in is http, not https. I changed it mexHttpsBinding and it worked great. I think http didn't work due to some configuration of running http locally but I am not sure.
I have a WCF 4 service which is in a Secure subfolder, accessible after the client has authenticated using Forms authentication using the .NET AuthenticationService.
This WCF service is for a mobile app client which communicates via json but is not an ASP.NET app. I have successfully configured the service to use json and the AuthenticationService has the standard configuration as documented in many places e.g. http://msdn.microsoft.com/en-us/library/bb398990.aspx
The docmentation for the AuthenticationService says "The application must be able to send and consume a SOAP message". However I want the client to be able to use json for authentication as well. Is this possible? What's the configuration required?
I found this article http://weblogs.asp.net/asptest/archive/2008/12/09/working-with-the-asp-net-ajax-authentication-service.aspx so it looks like the AuthenticationService can handle json but it uses Client Application Services. The mobile app client is not an ASP.NET app.
Yes the AuthenticationService can handle JSON. There are a couple of ways to do. Here is a sample configuration I've used in the past using the element.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="System.Web.ApplicationServices.AuthenticationService" behaviorConfiguration="MyServiceBehavior">
<endpoint address="" behaviorConfiguration="ajaxBehavior"
contract="System.Web.ApplicationServices.AuthenticationService"
binding="webHttpBinding" bindingConfiguration="webHttpBindingSecure"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="ajaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingSecure">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
The question is old for long time but I think it will help someone if I post my answer.
For sure you can return json for AuthenticationService.
The solution is very simple like Garret answer, you only need configure another endpoint like this but you need add 2 addition attributes for endpoint behaviors: defaultOutgoingResponseFormat="Json" and defaultBodyStyle="Wrapped" to overwrite default soap response.
<system.serviceModel>
<services>
<service behaviorConfiguration="AuthenticationServiceBehaviors" name="System.Web.ApplicationServices.AuthenticationService">
<endpoint address="" behaviorConfiguration="ajaxBehavior"
contract="System.Web.ApplicationServices.AuthenticationService"
binding="webHttpBinding" bindingConfiguration="RestBinding"
bindingNamespace="http://asp.net/ApplicationServices/v200"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="RestBinding" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="ajaxBehavior">
<webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="AuthenticationServiceBehaviors">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
I hope this help someone who want to expose asp.net membership as json format to use in mobile app.
I recently built a WCF Service, and now I'm deploying it to Windows Server 2008. Right now, we don't have secure protocol turned on. But we will. I'd like to get it working either way. In the site, I've had Anonymous authentication enabled as well as Forms authentication. The reason I did this was to prevent the authentication popup on the iPad, Android and Internet Explorer. So now they just get to the Login screen. Oh and I did activate WCF in Windows features. If you're also knowledgeable about making this https ready, I'd also like to figure that out. Thanks!!
I'm getting this error when I try pasting in the *.svc PATH into the URL.
System.ServiceModel.ServiceActivationException:
The service
'/WCFServices/Accessioning/QuickDataEntryService.svc'
cannot be activated due to an
exception during compilation
Here is my web.config configuration thus far.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<!--<baseAddressPrefixFilters>
<add prefix="http://localhost/" />
</baseAddressPrefixFilters>-->
</serviceHostingEnvironment>
<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
<!-- Watch this section when adding a new WCF Service! New behaviors will be added; just delete them and use "ServiceBehavior" -->
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior" name="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
<endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding"
contract="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<!--<service name="A.LIMS.UI.Web.WCFServices.Accessioning.IQuickDataEntryService"
behaviorConfiguration="ServiceBehavior">
<endpoint behaviorConfiguration="AspNetAjaxBehavior"
binding="webHttpBinding"
contract="A.LIMS.UI.Web.WCFServices.Accessioning.IQuickDataEntryService" />
</service>-->
<!-- Watch this section when adding a new WCF Service! Duplicate the "QuickDataEntryService" above for an example, but change the fully qualified name -->
</services>
</system.serviceModel>
I have no clue what caused the exception above, but here was the final verdict. There were a lot of things required for WCF and using an SSL certificate (HTTPS protocol). Pardon the formatting.. I don't like how Stack Overflow sometimes puts the code into a block and sometimes it doesn't.
The following were required for the web.config on HTTPS:
Here are some places that required the "requireSSL" attribute:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" timeout="30" protection="All" requireSSL="true" />
</authentication>
<httpCookies httpOnlyCookies="false" requireSSL="true" domain="" />
Notice the "s" in "httsGetEnabled" below:
<behaviors>
<endpointBehaviors>
<behavior name="AspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
Bindings (missing in non-SSL web.config):
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
Services (notice the "s" in "mexHttpsBinding"):
<services>
<service behaviorConfiguration="ServiceBehavior" name="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService">
<endpoint behaviorConfiguration="AspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="A.LIMS.UI.Web.WCFServices.Accessioning.QuickDataEntryService" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
Last but not least. I'm not using .NET 4.0, but I did try .NET on a different machine. With .NET 4.0 I couldn't get the WCF services to work without having this configured to the actual URL being used. If there were two domains for the same IP, WCF only worked with the domain in this block inside the system.ServiceModel XML block in the web.config. I did not test https in the .NET 4.0, so I'm assuming the protocol on the URL would be https below:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://subdomain.domain.com/" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
Oh, I also had to turn on WCF on the Windows Server 2008 box. And it required a server reboot!
Once again, as a beginner with WCF, MVC and Sharp Architecture, i might asking a stupid question, so bear with me.
I'm finally able to make the Northwind example of Sharp Architecture work.
I can browse the service using internet browser
localhost/NorthwindWcfServices/TerritoriesService.svc
localhost/NorthwindWcfServices/TerritoriesService.svc?wsdl
I can invoke the service GetTerritories using WcfTestClient.exe
And then i use Fiddler to test it :
Fiddler is ok when i Request a GET :
localhost/NorthwindWcfServices/TerritoriesService.svc?wsdl
when i start requesting
localhost/NorthwindWcfServices/TerritoriesService.svc/GetTerritories
They keep giving me a 400 Bad Request error.
Is there something i should do to make it work ?
Should i add a content-type in fiddler header request ? or should i add any attribute in the service class ?
Any help will be much appreciated.
Thanks
You have to configure the Service using the Web config file for example if u configure the WCF for accessing ... your service config should look something like this
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndPBehavior">
<webHttp/>
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceBehavior" name="CastleTest.WCF.WCFService">
<endpoint address="" binding="webHttpBinding"
contract="CastleTest.WCF.IWCFService"
behaviorConfiguration="EndPBehavior"/>
</service>
</services>
try it and see if the error 400 goes or not