I have been banging my head of the wall for two days with this so, hopefully, someone can give me a hand. What I have is a RESTful Web Service that I wrote using WCF; nothing to it really just two methods that accept a single string parameter and also return a string. Both the parameter and return value are straight XML.
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "/method1/{data}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)]
string Method1(string data);
[OperationContract]
[WebGet(UriTemplate = "/method2/{data}", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml)]
string Method2(string data);
}
For the sake of argument lets say that the implementation of both of these methods looks like this:
public string Method1(string data)
{
return string.Format("You entered: {0}", data);
}
If I goto http: //myuri.com/service.svc/method1/foo the following is wrote to the browser:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">You
entered: foo</string>
This works great but if I change the url to: http: //myuri.com/service.svc/method1/<foo > I get a 400 (Bad Request). So I enabled some tracers to see what was going using the following code:
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="All">
<listeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "c:\Traces.svclog" />
</listeners>
</source>
</sources>
As you can see I am using the switch value 'All' to capture every event that happens during the execution of this service. I ran back through a few times using the URL format that works to verify that the tracers were working and they were. I then went to the URL that contained the XML tag foo and recieved the 400 error as expected but when I went back to the log file there had been no additional information appened to the end of it. This leads me to believe that the 400 error is being displayed before the WCF service is ever invoked.
Lastly, I switched the the methods from 'GET' methods to 'POST' methods, wrote a bit of code using WebRequest / WebResponse with the same result. Now I have read some posts talking about using the XmlSerializer on the client side to send the data to the service but that defeats the purpose of this service. While I am using .NET to write the service it is likely that PHP or classic ASP scripts will be connecting to this service and they, obviously, do not have access to the XmlSerializer.
So my million dollar question is this: Is it possible to send a 'raw' XML request to a RESTful webservice developed in WCF and, if so, how?
P.S. The XML coming into and going out of the service is not based on any tangible object it is simply the structure I created to use with this service. The XML coming in is parsed via XPath, the values are placed into a larger XML string, and passed along to an external API. The results from that API are processed and then returned by my RESTful service.
Any help would be greatly appreciated!!