I am trying to create a post method in WCF application which takes the XML when the request is made. I was able to make the post method work whenever the client machine send the valid xml in request, however if the xml was invalid (e.g. if it had '&' sign) the post method would never get the request. The reason i want to capture the client's request whether if it has valid or invalid xml request is so that i can log client's request (i.e.xml input). I even created a post method with the string as parameter but still i was not able to debug the application when the request was made.
Here is the setup of post methods in WCF applicaton:
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat= WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/PostName/")]
string PostName(string name);
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/PostNameXml/")]
string PostNameXml(XElement name);
Here is the invalid xml input:
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Com&puter</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with XML.</description>
</book>
</catalog>
Here is what my web.config looks like:
<services>
<service behaviorConfiguration="ServiceBehavior" name="WCFTest.Service1">
<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="WCFTest.IService1" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
Do let me know if this can be done or not? Thanks.
Sanjeev
No comments:
Post a Comment