Help with SOAP

Hi all,

I’m trying to use Xojo SOAP to send a message to Adobe InDesign Server. They have lots of examples in PHP, C#, Java, etc., but of course not Xojo.

Something is going wrong with namespaces, and I’m not familiar enough with SOAP innards to know what’s wrong.

Here’s the code:

dim host As string = "http://localhost:12345" dim wsdlStr As string = host + "/Service?wsdl" Dim soap As New SOAPMethod(wsdlStr) soap.methodNamespace = "http://ns.adobe.com/InDesign/soap/" soap.Parameter("runScriptParameters") = "" // later there will be parameters, but that's a different battle dim sr as SOAPResult = soap.invoke("RunScript")

This runs without generating an exception, but the sr.errorMessage is: “Method ‘ns1:RunScript’ not implemented: method name or namespace not recognized”

I know that the method “RunScript” exists in the WSDL, because I’ve looked at the WSDL. And further, if I change “RunScript” to “SoapSucks” I get a SOAP exception telling me that “Method name does not exist in WSDL.”

If I look at the soap connection (which is an HTTPSocket) in the debugger, the _postContent is this:

<?xml version="1.0" encoding="UTF-8"?><SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:si="http://soapinterop.org/xsd"><SOAP:Body><ns1:RunScript xmlns:ns1="http://localhost:80/Service.wsdl"><ns1:runScriptParameters xsi:type="xsd:string"></ns1:runScriptParameters></ns1:RunScript></SOAP:Body></SOAP:Envelope>

You can see that it asks for “ns1:RunScript” but nowhere in this XML is “ns1” defined. Wouldn’t that be a problem? And isn’t that what the SOAP error is complaining about?

Anyone have any ideas?

Thanks!

Charles…

I do not use the Xojo built-in SOAP class… Instead I “grow my own”… so something like this:

dim hsock as new HTTPSocket
hsock.setPostContent soapRequestAsString, “text/xml”
response = hsock.post(theURL, timeout)

where soapRequestAsString is a properly formed xml SOAP request as a string. So you can build the request as an xml document then convert it to a string… or just create a string being very careful to match nodes and to convert any possible xml attributes.

soapRequestAsString would look like:

<?xml version='1.0' encoding='UTF-8'?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV=‘http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsd=‘http://www.w3.org/2001/XMLSchema
xmlns:xsi=‘http://www.w3.org/2001/XMLSchema-instance
xmlns:SOAP-ENC=‘http://schemas.xmlsoap.org/soap/encoding/
xmlns:ns4=‘http://ns.adobe.com/InDesign/soap/
SOAP-ENV:encodingStyle=‘http://schemas.xmlsoap.org/soap/encoding/’>

SOAP-ENV:Body
ns4:RunScript

javascript
ConvertXMLEntities(scriptText)

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

… where the “scriptText” is the text of entire javaScript you want IDS to run… and ConvertXMLEntities() is a function I wrote that converts all the possible xml entities… ex:. “<” becomes < If you don’t do this the request might not be well formed.

Or you can provide a file path in the node and leave your script in a file.

Hope this helps…

xojo soap methods only deal with simple parameters
and today’s soap server almost always have complex parameters
so xojo methods for soap are almost useless
make your own like in the above message.

Thanks James and Jean-yves. I will roll my own and give it a try. I’ll report on my results after I get done cursing XML, Xojo, Obamacare, and the Magna Carta.

Wow, that worked like a charm. Thank you guys, especially James for the detailed code!

[I’m not going to kvetch about how Xojo doesn’t support modern SOAP, as I suspect there’s only a very tiny fraction of people who need it and the Xojo folks have other things to do.]

Everyone should use soap…

I haven’t used SOAP for years. Which could explain why I have so few friends, and those that I have stay mostly upwind…

Trying to use SOAP-AXL in CUCM once again. Formed a request and am getting incorrect parameter when issuing a soap response. SOAP, REST, XML are areas I do not have a lot of strength in. If interested in further discussion send me an email cfitzsimmons@scgconnect.com