How To Force WCF Service To Use XmlSerializer Instead Of The DataContractSerializer



TODO:

Have you ever wanted to return Attributes, or have further control over serialization when using WCF?  By default, it uses the DataContractSerializer, but you can tell it to use the XmlSerializer.  

 

SOLUTION:

1.  Ensure you have your interface marked with [ServiceContract]

2.  Add XmlSerializerFormat to your method

 [ServiceContract]

 publicinterfaceIMyService


 [WebGet(UriTemplate = "employee")]

 [OperationContract]

 [XmlSerializerFormat]

 Response GetEmployees();

 

Now your WCF call will use the XmlSerializer rather than the DataContractSerializer.


NOTES:

There are no notes on this topic.

WebInvoke Verbs To Use With Restful WCF Service



TODO:

Have you ever wanted to know which verbs to use when defining your OperationContract in a WCF service?

 

SOLUTION:

// Get an employee by ID - GET - employee/id (  [WebGet(UriTemplate = "/employee/{id}")] )

// Create a new employee - POST - employee  [WebInvoke(Method = "POST", UriTemplate = "/employee/{xml}")] )

// Update an employee - PUT - employee/id  [WebInvoke(Method = "PUT", UriTemplate = "/employee/{xml}")]

// Delete an employee - DELETE - employee/id  [WebInvoke(Method = "DELETE", UriTemplate = "/employee/{id}")]

 

NOTES:

There are no notes on this topic

How To Fix "Endpoint not found" Error When Browsing Restful WCF Service In Visual Studio



TODO:

You try to view your Restful WCF service in a browser from Visual Studio and get the "Endpoint not found" error.

 

SOLUTION:

Right click on your .svc file.  Look for "Factory="= "System.ServiceModel.Activation.WebServiceHostFactory" and delete it.  You can now Right click your .svc file and choose "View in browser"

 

NOTES:

There are no notes on this topic

How To Throttle How Many Message Are Pulled From MSMQ



TODO:

You have an MSMQ that is wired to a WCF service.  You want to throttle how many messages are processed, so that you can better control the system resources.  To do so, you need to change the config file for your WCF...and add the following entries.

 

SOLUTION:

<behaviors>
 <serviceBehaviors>
  <behavior name="DefaultThrottlingBehavior">
   <serviceThrottling maxConcurrentCalls="jQuery15207601982052437961_1377884886133?"
          maxConcurrentSessions="???"
          maxConcurrentInstances="???" />
  </behavior>
 </serviceBehaviors>
</behaviors>

 

NOTES:

Replace the ??? with the values you want.  It may take some trial and error to see what settings work best.

How To Throttle How Many Message Are Pulled From MSMQ



TODO:

You have an MSMQ that is wired to a WCF service.  You want to throttle how many messages are processed, so that you can better control the system resources.  To do so, you need to change the config file for your WCF...and add the following entries.

 

SOLUTION:

<behaviors>
 <serviceBehaviors>
  <behavior name="DefaultThrottlingBehavior">
   <serviceThrottling maxConcurrentCalls="xxx"
          maxConcurrentSessions="xxx"
          maxConcurrentInstances="xxx" />
  </behavior>
 </serviceBehaviors>
</behaviors>

 

NOTES:

Replace the 'xxx' with the values you want.  It may take some trial and error to see what settings work best.

How To Throttle How Many Message Are Pulled From MSMQ



TODO:

You have an MSMQ that is wired to a WCF service.  You want to throttle how many messages are processed, so that you can better control the system resources.  To do so, you need to change the config file for your WCF...and add the following entries.

 

SOLUTION:

<behaviors>
 <serviceBehaviors>
  <behavior name="DefaultThrottlingBehavior">
   <serviceThrottling maxConcurrentCalls="jQuery15207601982052437961_1377884886134?"
          maxConcurrentSessions="???"
          maxConcurrentInstances="???" />
  </behavior>
 </serviceBehaviors>
</behaviors>

 

NOTES:

Replace the ??? with the values you want.  It may take some trial and error to see what settings work best.

How To Throttle How Many Message Are Pulled From MSMQ



TODO:

You have an MSMQ that is wired to a WCF service.  You want to throttle how many messages are processed, so that you can better control the system resources.  To do so, you need to change the config file for your WCF...and add the following entries.

 

SOLUTION:

<behaviors>
 <serviceBehaviors>
  <behavior name="DefaultThrottlingBehavior">
   <serviceThrottling maxConcurrentCalls="jQuery15207601982052437961_1377884886132?"
          maxConcurrentSessions="???"
          maxConcurrentInstances="???" />
  </behavior>
 </serviceBehaviors>
</behaviors>

 

NOTES:

Replace the ??? with the values you want.  It may take some trial and error to see what settings work best.

How To Throttle How Many Message Are Pulled From MSMQ



TODO:

You have an MSMQ that is wired to a WCF service.  You want to throttle how many messages are processed, so that you can better control the system resources.  To do so, you need to change the config file for your WCF...and add the following entries.

 

SOLUTION:

<behaviors>
 <serviceBehaviors>
  <behavior name="DefaultThrottlingBehavior">
   <serviceThrottling maxConcurrentCalls="xxx"
          maxConcurrentSessions="xxx"
          maxConcurrentInstances="xxx" />
  </behavior>
 </serviceBehaviors>
</behaviors>

 

NOTES:

Replace the xxx with the values you want.  It may take some trial and error to see what settings work best.