sabato 17 marzo 2012

XML in Webservice call


Today many web services offers flexible operation with  xml  input parameter.
This design strategy  offers very stable web service interface (but not very self explaining in input parameters)  at cost of no soap based request check on server side (server must implement other kind of xml validation).
If you use any client to test your web services (es. soap ui) you have to insert an XML in your request but you have to insert special CDATA signature as follows in this sample:

This is client request for myweb service (an spml based one) prototype generated with soap UI:
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.appif.app.company.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:provisioningRequest>
         <parameters>
            <spmlReq> 
</spmlReq>
            <responseUrl>?</responseUrl>
         </parameters>
      </ws:provisioningRequest>
   </soapenv:Body>
</soapenv:Envelope>
Basically my web service offers provisioningRequest operation with spmlReq parameter (XML goes there) and an optional responseUrl parameter (for asyncronous responses).

To insert XML put CDATA envelope as follows:



<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.appif.app.company.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <ws:provisioningRequest>
         <parameters>
            <spmlReq> 
<![CDATA[<spml:searchRequest xmlns:spml='urn:oasis:names:tc:SPML:1:0' xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core'>
                  <spml:identifier type='urn:oasis:names:tc:SPML:1:0#GUID'>
                    <spml:id>123456789</spml:id>
                  </spml:identifier>
                  <spml:attributes>
                    <dsml:attribute name='CountCallActiveSim'/>
                  </spml:attributes>
                </spml:searchRequest>
]]>

</spmlReq>
            <responseUrl>?</responseUrl>
         </parameters>
      </ws:provisioningRequest>
   </soapenv:Body>
</soapenv:Envelope>


Nessun commento:

Posta un commento