0

I want to access an online program via the command line within a bash script. I've been told I can run a SOAP request in order to access the software. This is the request I've been told I can use.

POST /OnlineAnalysis/Service.asmx HTTP/1.1
Host: cydas.org
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.cydas.org/OnlineAnalysis/analyseKaryotype"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <analyseKaryotype xmlns="http://www.cydas.org/OnlineAnalysis/">
      <strKaryotype>string</strKaryotype>
    </analyseKaryotype>
  </soap:Body>
</soap:Envelope>

I've never run a SOAP request before but it looks like I'm able to use the curl command based on this question. I've tried to model my curl command according to the link I posted

curl -X POST -H "POST /OnlineAnalysis/Service.asmx HTTP/1.1" -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction: \"http://www.cydas.org/OnlineAnalysis/analyseKaryotype\"" -H "Host: cydas.org" --data-binary @request.xml

And am getting this output

<HTML>
<HEAD>
<TITLE>405 Method Not Allowed</TITLE>
<BASE href="/error_docs/"><!--[if lte IE 6]></BASE><![endif]-->
</HEAD>
<BODY>
<H1>Method Not Allowed</H1>
The HTTP verb used to access this page is not allowed.<P>
<HR>
<ADDRESS>
Web Server at &#99;&#121;&#100;&#97;&#115;&#46;&#111;&#114;&#103;
</ADDRESS>
</BODY>
</HTML>

<!--
- Unfortunately, Microsoft has added a clever new
- "feature" to Internet Explorer. If the text of
...

These are the contents of my request.xml file below

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <analyseKaryotype xmlns="http://www.cydas.org/OnlineAnalysis/">
      <strKaryotype>46,XX,del(3)(p11)</strKaryotype>
    </analyseKaryotype>
  </soap:Body>
</soap:Envelope>

I'm not sure what the expected output is supposed to be yet because I can't run the program. I just want to get my SOAP request running properly.

Sam
  • 1,765
  • 11
  • 82
  • 176

1 Answers1

1

try this:

curl -v "http://www.cydas.org/OnlineAnalysis/Service.asmx" -H "Content-Type: text/xml;charset=UTF-8" -H "SOAPAction: \"http://www.cydas.org/OnlineAnalysis/analyseKaryotype\"" -H "Connection: Keep-Alive" -H "Host: www.cydas.org" --data @request.xml

The server responded with the message: "The Karyotype del(3)(p11) is not valid: Non-specified error in chromosome count element (del(3)(p11))"

Here's the complete response message:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<analyseKaryotypeResponse xmlns="http://www.cydas.org/OnlineAnalysis/">
<analyseKaryotypeResult>
<Original_ISCN_Formula>del(3)(p11)</Original_ISCN_Formula>
<IsPolyClonal>false</IsPolyClonal>
<IsValidKaryotype>false</IsValidKaryotype>
<Corrected_ISCN_Formula/>
<CloneSize>0</CloneSize>
<IsIncompleteKaryotype>false</IsIncompleteKaryotype>
<Ploidy>0</Ploidy>
<ErrorMessages>The Karyotype del(3)(p11) is not valid:
Non-specified error in chromosome count element (del(3)(p11))</ErrorMessages>
</analyseKaryotypeResult>
</analyseKaryotypeResponse>
</soap:Body>
</soap:Envelope>

cURL is a great tool, but if you want a nice gui you can try other tools like SoapUI or Postman for testing APIs. SoapUI is a standalone Java application and Postman is a plugin for Chrome. They're both free.

exaudio
  • 36
  • 5
  • Thank-you, I have a question about analyzing the output (I edited my request.xml file so that an error is no longer produced). I think it's all in xml so do you have a suggestion for a tool or some commands that are able to extract what I want from the output? `In my example I want the blocks where xsi:type="GainLossStruct" and # || # where # is greater than 0` – Sam Jun 05 '17 at 23:54
  • You're correct. The response you get from the from that web service is a SOAP message which is xml. Most programing languages have libraries that will allow you to work with SOAP web services which makes it relativity easy to write some code to make your request to the web service and then receive the response. If you find the right library it should understand the SOAP message and be able to parse it into an object that you can work with. Since you mentioned you were trying to do this in a shell script you might look at this example: – exaudio Jun 06 '17 at 03:01
  • Here's the example: [https://www.codeproject.com/Tips/1015753/Calling-SOAP-WebService-And-Parsing-The-Result-Fro] – exaudio Jun 06 '17 at 03:08
  • Do you know how to silence the output? I'm trying to the add the -s and --silent options, but am not getting any success. I don't want these lines to appear * ` Trying 85.25.198.77... * TCP_NODELAY set * Connected to www.cydas.org (85.25.198.77) port 80 (#0) > POST /OnlineAnalysis/Service.asmx HTTP/1.1 > Host: www.cydas.org > User-Agent: curl/7.51.` ... – Sam Jun 09 '17 at 03:32
  • 1
    @Jacob, sure, I think that's the output from using the -v (verbose) switch in the curl command. Just remove the -v. – exaudio Jun 09 '17 at 04:01
  • @Jacob, yeah, if you remove the -v then the -s should keep it silent. Also, you can have curl output the response to a file instead of the screen. Try this curl string: `curl -s "http://www.cydas.org/OnlineAnalysis/Service.asmx" -H "Content-Type: text/xml;charset=UTF-8" -H "SOAPAction: \"http://www.cydas.org/OnlineAnalysis/analyseKaryotype\"" -H "Connection: Keep-Alive" --data @request.xml -o response.xml` I tried using a karyotype from one of their examples and was able to get a valid response with the gains and losses you mentioned. – exaudio Jun 09 '17 at 04:23
  • Here's the contents of the request.xml file that worked for me: ` 47,XY,t(9;22)(q34;q11),+der(22)(?::22p112->22q112::9q34->9qter) ` – exaudio Jun 09 '17 at 04:29