Interfaces/SOAP Call

From J Wiki
Jump to: navigation, search

Using Scripts/HTTP Get utility J can be used as a client to a SOAP Web Service.

Here we will use an explicit definition of a SOAP body and HTTP request, which is obtained from a SOAP Client utility.

soapBody=: 0 : 0
<?xml version="1.0" encoding="UTF-8"?>
  <m:DoR xmlns:m="">
    <input xsi:type="xsd:string">%1</input>

Note: the actual value is represented as parameter %1, which is substituted using the wrapper verb.

soapTest=: 3 : 0
  require 'user/httpget.ijs regex'
Heads_phttpget_=: ,:'SoapAction';''
  q=. soapBody rplc '%1';y
  r=. q httpget'http://localhost/JApp/JDLLServer.3.soap'
  '<v [^>]+>([^<]+)</v>' (,.@{:@rxmatch ];.0 ]) r

regex is used to obtain the value of the result.

Here's how this verb is called:

   soapTest_phttpget_']a=: i.2 3'
0 1 2
3 4 5

   soapTest_phttpget_'+/ a'
3 5 7