WSE 2 RequestDescription action
Yesterday I spent a few hours testing interesting aspects of the release of WSE 2.0. I want to expose a particularly nice point about the recent SoapService implementation and WSDL. One of the most remarkable aspects of WSE 2.0 since the technology preview version is the possibility to develop high and low level SOAP-based messaging applications that can run in a transport independent manner. In English, we can develop a SOAP Service or SOAPReceiver application that can be hosted using either HTTP, TCP, UDP, etc protocols.
In the case of SOAPService hosted using HTTP (.ashx) we can now obtain the WSDL using a , surprise, ?wsdl query. The problem is that this method does not work for SOAPService hosted using other protocols like TCP. However WSE 2.0 provides an interesting mechanism to obtain the description of a SOAPService in a protocol independent manner.
In a past post I cover the notable aspects of WS-MetaDataExchange specification. This specification makes possible to obtain three types of metadata using well defined SOAP message pairs. Using these message we can obtain the WS-Policy associated with the receiving endpoint, the XML Schema with a given target namespace and, of course, the WSDL associated with the receiving endpoint. Using the following WS-MetaDataExchange message we can request the WSDL of the receiving endpoint.
<s:Envelope ...> <s:Header ...> <wsa:Action> http://schemas.xmlsoap.org/ws/2004/02/mex/GetWSDL/Response </wsa:Action> <wsa:RelatesTo>xs:anyURI</wsa:RelatesTo> ? <wsa:To>xs:anyURI</wsa:To> ... </s:Header> <s:Body ...> <wsx:GetWSDLResponse> <wsdl:definitions ...> ... </wsdl:definitions> + </wsx:GetWSDLResponse> </s:Body> </s:Envelope> |
As we can see we put the http://schemas.xmlsoap.org/ws/2004/02/mex/GetWSDL/Response action and add a simple Body to the message. Well, WSE 2.0 provides a similar mechanism to obtain the WSDL. Suppose that we have a SOAPService that are currently hosted by an application using one protocol different from HTTP. We can send a SOAP message with the following action http://schemas.microsoft.com/wse/2003/06/RequestDescription and an empty body and in response we obtina the WSDL. The following Three lines shows the necessary code.
SoapEnvelope env= new SoapEnvelope(); env.Context.Addressing.Action= "http://schemas.microsoft.com/wse/2003/06/RequestDescription"; SoapEnvelope ResultEnv= SendRequestResponse("", env); |
The SOAP message produced must contain the RequestDescription action
<soap:Envelope xmlns:wsa=".." xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <wsa:Action> http://schemas.microsoft.com/wse/2003/06/RequestDescription <wsa:Action> </soap:Header> <soap:Body /> </soap:Envelope> |
I think that is a very useful aspect. Enjoy it.