Interfaces/Mac SOAP Client

From J Wiki
Jump to: navigation, search

We shall explore how to consume the Web Service defined in Windows with clients in Mac OS X.

Discovering Web Service

A great tool for doing web service discovery on Mac is SOAP Client.

We run the SOAP Client and point it to our JApp service, using the URL


It quickly parses the WSDL and fills out the necessary detail: Service name and list of methods; and for each method: Endpoint URI, SOAP Action, Namespace and parameters.

It is ready to execute DoR method with i.2 3 input parameter:

Host: host
User-Agent: Mac OS X; WebServicesCore.framework (1.1.0)
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
        <m:DoR xmlns:m="">
          <input xsi:type="xsd:string">i.2 3</input>

which returns the following response.

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1, MS .NET Remoting, MS .NET CLR 2.0.50727.42
Connection: close
X-Aspnet-Version: 2.0.50727
Date: Sun, 15 Apr 2007 11:15:40 GMT
Content-Length: 952
Cache-Control: private
Content-Type: text/xml; charset="utf-8"

<SOAP-ENV:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:SOAP-ENC="" xmlns:SOAP-ENV="" xmlns:clr="" SOAP-ENV:encodingStyle="">
    <h4:__CallContext href="#ref-3" xmlns:h4="" SOAP-ENC:root="1"/>
    <a1:LogicalCallContext id="ref-3" xmlns:a1="">
    <i5:DoRResponse id="ref-1" xmlns:i5="">
      <v id="ref-6" xsi:type="SOAP-ENC:string">0 1 2
3 4 5

Not only strings can be passed over. In fact all the powerful COM Variant marshalling with Get/Set methods are passed on to SOAP types.

Here we assign i.2 3 to name a and use Get to obtain the value of a. The body of response looks like this (note two-dimensional array representation as int[2,3]:

<i5:GetResponse id="ref-1" xmlns:i5="">
  <v href="#ref-6"/>
<SOAP-ENC:Array id="ref-6" SOAP-ENC:arrayType="xsd:int[2,3]">

Automator Web Service Client

Automator has an action for calling web services, which will be used with discovery parameters above to call J SOAP service.

The workflow consists of three actions:

  • Run AppleScript (Get J Input)
on run {input, parameters}
	display dialog "Enter J expression" default answer "i.2 3"
	return {input:text returned of result}
end run
  • Run Web Service (J SOAP Service)


  • Run AppleScript (Show J Response)
on run {input, parameters}
	display alert "J Responded" message (get v of item 2 of input)
	return input
end run

The SOAP input and results as AppleScript objects in a couple of Automator sessions

AutoSess1.png AutoSess2.png
{{input:"] b=: 2 3 ?@$ 0"}, {v:"0.971379 0.0466292 0.330109

0.01346 0.220004 0.600044", |return|:"0"}}

{{input:"+/ b"}, {v:"0.984839 0.266633 0.930153", |return|:"0"}}

See Also