[Fedora-suds-list] Python suds client -> php service -- inputStringArray problem

Jerry Davis jerry.davis at pearson.com
Fri Sep 3 20:25:56 UTC 2010


Ok. I am a wits end here.

We have a php service, some of the methods use something in php called a
inputStringArray

I have filled out the inputStringArray's and and php does not like it. I can
send a ONE item array, but not TWO or more.

Note: In the following pay attention to the tokens and values, which are
inputStringArray's.

-------------------------
Python client code:

tokens = soap.factory.create('inputStringArray')
tokens.item = ['{token1}', '{token2}']

values = soap.factory.create('inputStringArray')
values.item = ['elmer.fudd', 'some_link.com']

dosendmail = True

#sendMailTemplate(xs:string to,
#                 xs:string from,
#                 xs:string subject,
#                 xs:string template_name,
#                 inputStringArray replace_tokens,
#                 inputStringArray replace_values,
#                 xs:boolean html,
#                 xs:boolean output, )

import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('suds.client').setLevel(logging.DEBUG)

text = soap.service.sendMailTemplate(mto, mfrom, msubject, mtemplate,
tokens, values, False, True)

The SOAP message that gets sent is:

MESSAGE:
<SOAP-ENV:Envelope xmlns:ns3="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns0="http://schemas.xmlsoap.org/   soap/encoding/"
xmlns:ns1="urn:myservice"
xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Header/>
   <ns2:Body>
      <ns1:sendMailTemplate>
         <to xsi:type="ns3:string">my at emailaddress.com</to>
         <from xsi:type="ns3:string">my at emailaddress.com</from>
         <subject xsi:type="ns3:string">test from sendmail.py</subject>
         <template_name
            xsi:type="ns3:string">ldap_usr_reset_template</template_name>
         <replace_tokens xsi:type="ns1:inputStringArray">
            <item xsi:type="ns3:string">{token1}</item>
            <item xsi:type="ns3:string">{token2}</item>
         </replace_tokens>
         <replace_values xsi:type="ns1:inputStringArray">
            <item xsi:type="ns3:string">elmer.fudd</item>
            <item xsi:type="ns3:string">some_link.com</item>
         </replace_values>
         <html xsi:type="ns3:boolean">false</html>
         <output xsi:type="ns3:boolean">true</output>
      </ns1:sendMailTemplate>
   </ns2:Body>
</SOAP-ENV:Envelope>
DEBUG:suds.transport.http:received:
CODE: 200

-----------------------------

php client code:

$text .= $client->call('sendMailTemplate',
             array('to' => 'my at emailaddress.com',
                   'from' => 'my at emailaddress.com',
                   'subject' => 'Test Template SOAP API',
                   'template_name' => 'ldap_usr_reset_template',
                   'replace_tokens' => array('{token1}', '{token2}'),
                   'replace_values' => array('elmer.fudd', 'some_link.com'),
                   'html' => false,
                   'output' => true));

Here is the request:

POST blahblah.php?wsdl HTTP/1.0
Host: ahost-mbp:10088
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: "" 
Authorization: Basic blah
Content-Length: 1228
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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/">
  <SOAP-ENV:Body>
    <ns4007:sendMailTemplate xmlns:ns4007="http://tempuri.org">
      <to xsi:type="xsd:string">my at emailaddress.com</to>
      <from xsi:type="xsd:string">my at emailaddress.com</from>
      <subject xsi:type="xsd:string">Test Template SOAP API</subject>
      <template_name
          xsi:type="xsd:string">ldap_usr_reset_template</template_name>
      <replace_tokens xsi:type="SOAP-ENC:Array"
       SOAP-ENC:arrayType="xsd:string[2]">
        <item xsi:type="xsd:string">{token1}</item>
        <item xsi:type="xsd:string">{token2}</item>
      </replace_tokens>
      <replace_values xsi:type="SOAP-ENC:Array"
       SOAP-ENC:arrayType="xsd:string[2]">
        <item xsi:type="xsd:string">elmer.fudd</item>
        <item xsi:type="xsd:string">some_link.com</item>
      </replace_values>
      <html xsi:type="xsd:boolean">0</html>
      <output xsi:type="xsd:boolean">1</output>
    </ns4007:sendMailTemplate>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


-------------------------
Comparison of python vs. php code as far as tokens and values is concerned

python:

         <replace_tokens xsi:type="ns1:inputStringArray">
            <item xsi:type="ns3:string">{token1}</item>
            <item xsi:type="ns3:string">{token2}</item>
         </replace_tokens>
         <replace_values xsi:type="ns1:inputStringArray">
            <item xsi:type="ns3:string">elmer.fudd</item>
            <item xsi:type="ns3:string">some_link.com</item>
         </replace_values>

php:

      <replace_tokens xsi:type="SOAP-ENC:Array"
       SOAP-ENC:arrayType="xsd:string[2]">
        <item xsi:type="xsd:string">{token1}</item>
        <item xsi:type="xsd:string">{token2}</item>
      </replace_tokens>
      <replace_values xsi:type="SOAP-ENC:Array"
       SOAP-ENC:arrayType="xsd:string[2]">
        <item xsi:type="xsd:string">elmer.fudd</item>
        <item xsi:type="xsd:string">some_link.com</item>
      </replace_values>

There is no error at all, but the expected results do not come back. It is
like the php service does not understand what I am sending it.

And it all boils down to the inputStringArray.

Does someone know what I am doing wrong?

Jerry



More information about the suds mailing list