Looking at http://msdn.microsoft.com/en-us/library/ms731303.aspx, and http://msdn.microsoft.com/en-us/library/ms789007.aspx, examples are given which specify ServiceBehavior, but is there a way to specify an endpointBehavior in the behaviorConfiguration as well? Something like
<service name="ServiceName1" behaviorConfiguration="ServiceBehavior1;EndpointBehavior1">
...
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior1">
...
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpointBehavior1">
...
</behavior>
</endpointBehaviors>
</behaviors>
...
Silly question, The endpoint element of the web.config also has its own behaviorConfiguration attribute.
<endpoint
behaviorConfiguration="EndpointBehavior1" ...
Related
When I enter the address of my service, I get to see the WSDL file. However, When I add a suffix to the URL, I get the error message: "endpoint not found". It's definitely due to something wrong with my service model declaration but after a few hours, I'm inclined to admit that it's beyond me.
I've made sure that the namespaces are correct as discussed here.
The first URL works. The other, don't.
http://---.azurewebsites.net/MyService.svc/
http://---.azurewebsites.net/MyService.svc/Ping
http://---.azurewebsites.net/MyService.svc/Ping/ (as suggested here)
In behaviors I've declared two behaviors - one for the end point and one for the service.
<behaviors>
<endpointBehaviors>
<behavior name="PingEndPointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name ="PingServiceBehavior">
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true"
httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
I declared the following binding for access via URL line in the browser.
<bindings>
<webHttpBinding></webHttpBinding>
</bindings>
In services I declared two end points (I tested with only the first one, as well).
<service name="MyProject.MyService"
behaviorConfiguration="PingServiceBehavior">
<endpoint name="PingEndPoint"
behaviorConfiguration="PingEndPointBehavior"
address="Ping"
binding="webHttpBinding"
contract="MyProject.IMyService"/>
<endpoint contract="IMetadataExchange"
binding="mexHttpBinding"
address="mex" />
</service>
I also have the following in my config file. Doubtful of its significance, but one never knows.
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true"/>
I've resolved the issue. Apparently, the virtual path of sub-directories is cumulative, so the exposed service was there all along but at the following address.
http://---.azurewebsites.net/MyService.svc/Ping/Ping
One ping level comes from the config file while the other from the template URI in the attribute that decorates the interface for the method.
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="EndpBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<standardEndpoints>
<webScriptEndpoint>
<standardEndpoint name="" crossDomainScriptAccessEnabled="true" />
</webScriptEndpoint>
</standardEndpoints>
<services>
<service behaviorConfiguration="ServiceBehavior" name="Service">
<endpoint address="" binding="webHttpBinding" contract="IService" behaviorConfiguration="EndpBehavior"/>
</service>
</services>
</system.serviceModel>
What do I need to change in web config after deploying my WCF service on IIS?
My code is running with two projects.
Your service and contract name should be a fully qualified names.
check this
Suppose I have a WCF Service hosted in IIS, can the address in endpoint be empty?
I saw an example at WCF Tutorial.
<system.serviceModel>
<services>
<service name="MathService"
behaviorConfiguration="MathServiceBehavior">
<endpoint address="" contract="IMathService"
binding="wsHttpBinding"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MathServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
If endpoint address is empty, it will use BaseAddress specified by the ServiceHost when you instantiate your service.
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 am having issues specifying the dataContractSerializer maxItemsInObjectGraph in host's web.config.
<behaviors>
<serviceBehaviors>
<behavior name="beSetting">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyNamespace.MyService"
behaviorConfiguration="beSetting" >
<endpoint address="http://localhost/myservice/"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding1"
contract="MyNamespace.IMyService"
bindingNamespace="MyNamespace">
</endpoint>
</service>
</services>
The above has no effect on my data pull. The server times out because of the large volume of data.
I can however specify the max limit in code and that works
[ServiceBehavior(MaxItemsInObjectGraph=2147483646, IncludeExceptionDetailInFaults = true)]
public abstract class MyService : MyService
{
blah...
}
Does anyone know why I can't make this work through a web.config setting? I would like to keep in the web.config so it is easier for future updates.
In your behavior section, add an endpoint behavior with the dataContractSerializer, like so:
<endpointBehaviors>
<behavior name="LargeQuotaBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</endpointBehaviors>
Then modify your endpoint to use this behavior like so:
<endpoint address="http://localhost/myservice/"
binding="webHttpBinding"
bindingConfiguration="webHttpBinding1"
contract="MyNamespace.IMyService"
bindingNamespace="MyNamespace"
behaviorConfiguration="LargeQuotaBehavior">
This should solve your problem.