am loosing xml content when calling wcf service via post. I see only "<" to wcf method. Am passing xml content like this: samplesample.
Client:
jQuery.support.cors = true;
$.ajax({
type: 'POST',
url: 'http://localhost:48677/MYSVC.svc/ParseXML/<?xml version=1.0 encoding=UTF-8?><node>sample</node><node1>sample</node1>',
cache: false,
contentType: 'text/xml;charset=UTF-8',
dataType: 'json',
processData: true,
success: function (msg) {
},
error: function (err) {
}
});
Service Interface:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.WrappedRequest, UriTemplate = "ParseXML/{xmlContent}")]
Stream ParseXML(string xmlContent);
Also incorporated wrapper as per: http://vivekcek.wordpress.com/2012/06/14/wcf-rest-service-accepting-raw-xml-webcontenttypemapper/
If I pass non-xml string, my service get called but proper xml content it is not.
Also included following line in both service & asp.net web.config:
<httpRuntime requestValidationMode="2.0" maxUrlLength="4096" requestPathInvalidCharacters="" useFullyQualifiedRedirectUrl="true" maxRequestLength="2147483647" requestLengthDiskThreshold="2147483647" executionTimeout="18000" targetFramework="4.5"/>
I also tried with this: requestPathInvalidCharacters="<,>,*,%,:,\,?" but didn't help
Please guide me how to pass proper xml content to wcf!
Updated:
WHile calling service from httpwebresponse, am getting below error:
The server encountered an error processing the request. The exception message is 'Incoming message for operation 'ParseXML' (contract 'IXmlParseService' with namespace 'http://tempuri.org/') contains an unrecognized http body format value 'Xml'. The expected body format value is 'Raw'. This can be because a WebContentTypeMapper has not been configured on the binding. See the documentation of WebContentTypeMapper for more details.'. See server logs for more details. The exception stack trace is:
at System.ServiceModel.Dispatcher.HttpStreamFormatter.GetStreamFromMessage(Message message, Boolean isRequest) at System.ServiceModel.Dispatcher.HttpStreamFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.UriTemplateDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.CompositeDispatchFormatter.DeserializeRequest(Message message, Object[] parameters) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)