My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
Curl  
Post XML Request From Command Line.
Phase-Implementation, Phase-Support
Updated Jun 24, 2009 by John.Jian.Fang@gmail.com

What if you do not have UI in the Linux system, but you want to test your REST or SOAP web services? You can use a Linux tool curl to achieve this.

Request XML

First, you need to create the request XML file. For example, I have a sign on service to login, the SOAP message looks as follows,

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sig="http://mycompany.ws/services/SignOnService" xmlns:ent="http://mycompany.ws/entities">
   <soapenv:Header/>
   <soapenv:Body>
      <sig:login>
         <ent:LoginRequest>
            <ent:context>
               <ent:locale>us_EN</ent:locale>
               <ent:taskId>default</ent:taskId>
            </ent:context>
            <ent:password>P@ssw0rd</ent:password>
            <ent:userId>jfang</ent:userId>
         </ent:LoginRequest>
      </sig:login>
   </soapenv:Body>
</soapenv:Envelope>

Post Request Using Curl

The command is

[jfang@localhost ~]$ curl -k --request POST --header "Content-type: text/xml" --data @loginrequest.xml https://localhost:8843/server/SignOnService

and the response message will be dumped out as follows,

<?xml version="1.0" ?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:loginResponse xmlns:ns2="http://mycompany.ws/services/SignOnService"
                           xmlns:ns3="http://mycompany.ws/entities">
            <ns3:EmployeeAuthenticationResponse>
                <ns3:responseType>NORMAL</ns3:responseType>
                <ns3:isSuccessful>true</ns3:isSuccessful>
                <ns3:returnValue>
                    <ns3:isAuthenticated>true</ns3:isAuthenticated>
                    <ns3:employee>
                        <ns3:person>
                            <ns3:firstName>Jian</ns3:firstName>
                            <ns3:lastName>Fang</ns3:lastName>
                        </ns3:person>
                        <ns3:userId>jfang</ns3:userId>
                    </ns3:employee>
                    <ns3:roles>
                        <ns3:description>QCSupervisor</ns3:description>
                        <ns3:name>QCSupervisor</ns3:name>
                        <ns3:roleId>170</ns3:roleId>
                    </ns3:roles>
                    <ns3:ticketId>TGT-100023-kVMpsxODT5mQqbgbyEPoWduF5olvmT12-JTV</ns3:ticketId>
                </ns3:returnValue>
            </ns3:EmployeeAuthenticationResponse>
        </ns2:loginResponse>
    </S:Body>
</S:Envelope>
Comment by excela...@gmail.com, Sep 9, 2014

Your blog is very useful. i got more than information about word press. its really wonderful blog. pls added more than tips. Nice sharing. i'm working in a <a http://www.excelanto.com/wordpress-cms-company-chennai.php>cms </a>in chennai.Here providing very low price cms , responsive webdesign and ERP. you have any more than information kindly make me call this number 044-42127512 or send your mail info@excelanto.com.

Comment by excela...@gmail.com, Oct 25, 2014

Thanks for your valuable posting.I have collect more than information from your website. It's really wonderful blog. please added more than tips. i'm working in a <a href="http://www.excelanto.com/wordpress-cms-company-chennai.php">cms in chennai</a>.Here providing very low price CMS , responsive webdesign and ERP. you have any more than information kindly make me call this number 044-42127512 or send your mail info@excelanto.com.

Comment by excela...@gmail.com, Oct 25, 2014

Thanks for your valuable posting.I have collect more than information from your website. It's really wonderful blog. please added more than tips. i'm working in a <a href="http://www.excelanto.com/">cms in chennai</a>.Here providing very low price CMS , responsive webdesign and ERP. you have any more than information kindly make me call this number 044-42127512 or send your mail info@excelanto.com.

Powered by Google Project Hosting