Loading ...
Sorry, an error occurred while loading the content.

Problem contacting a Java SOAP server

Expand Messages
  • gnustavo
    Hi. I m having a problem with my module JIRA::Client (http://search.cpan.org/~gnustavo/JIRA-Client/) which uses SOAP::Lite to implement an extended interface
    Message 1 of 2 , Dec 10, 2009
    View Source
    • 0 Attachment
      Hi. I'm having a problem with my module JIRA::Client (http://search.cpan.org/~gnustavo/JIRA-Client/) which uses SOAP::Lite to implement an extended interface to JIRA's SOAP API, which is specified at http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/com/atlassian/jira/rpc/soap/JiraSoapService.html.

      I'm failing to call a specific method which has this Java signature:

      boolean addBase64EncodedAttachmentsToIssue(java.lang.String token,
      java.lang.String issueKey, java.lang.String[] fileNames,
      java.lang.String[] base64EncodedAttachmentData)

      The script I use to call it tries to attach a file to a ticket in the public JIRA instance at Atlassian. Anyone can try it. Like this:

      -------------
      #!/usr/bin/perl

      use MIME::Base64;
      use JIRA::Client;

      my $jira = JIRA::Client->new('http://jira.atlassian.com/',
      'soaptester', 'soaptester');

      $jira->addBase64EncodedAttachmentsToIssue('TST-20616', ['file1.txt'],
      [encode_base64("Test from JIRA::Client.\n")]);
      ----------------------------

      When I run it I get the following error: "soapenv:Server.userException: java.lang.ArrayStoreException:
      [Ljava.lang.String;"

      The low-level call that my module do to SOAP::Lite is like this:

      $soaplite->call('addBase64EncodedAttachmentsToIssue',
      '08FiZ3A5Cu', 'TST-20616', ['file1.txt'],
      ['VGVzdCBmcm9tIEpJUkE6OkNsaWVudC4K']);

      The first two arguments must be correct because they are used in several other methods which work fine. The problem must be with one of the array arguments.

      I downloaded a Java client that implements the API and used it succesfully to call the addBase64EncodedAttachmentsToIssue method. Sniffing the network I grabbed the SOAP XML on the wire to compare it with the one generated by SOAP::Lite. There are some differences but I don't know enough SOAP to see which one could be the problem.

      The XML produced by the Java client interaction is this:

      --------------------------
      # CALL login
      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <ns1:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns1="http://soap.rpc.jira.atlassian.com">
      <in0 xsi:type="xsd:string">soaptester</in0>
      <in1 xsi:type="xsd:string">soaptester</in1>
      </ns1:login>
      </soapenv:Body>
      </soapenv:Envelope>
      # RESPONSE
      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <ns1:loginResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns1="http://soap.rpc.jira.atlassian.com">
      <loginReturn xsi:type="xsd:string">Y1nU54fr3T</loginReturn>
      </ns1:loginResponse>
      </soapenv:Body>
      </soapenv:Envelope>


      # CALL addBase64EncodedAttachmentsToIssue
      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <ns1:addBase64EncodedAttachmentsToIssue
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns1="http://soap.rpc.jira.atlassian.com">
      <in0 xsi:type="xsd:string">Y1nU54fr3T</in0>
      <in1 xsi:type="xsd:string">TST-20616</in1>
      <in2 soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <in2 xsi:type="xsd:string">attachment643562722194294045760.txt</in2>
      </in2>
      <in3 soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
      <in3 xsi:type="xsd:string">QSBzYW1wbGUgZmlsZSBhdHRhY2hlZCB2aWEgU09BUCB0byBKSVJBIGlzc3VlIFRTVC0yMDYxNg==</in3>
      </in3>
      </ns1:addBase64EncodedAttachmentsToIssue>
      </soapenv:Body>
      </soapenv:Envelope>
      # RESPONSE
      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <ns1:addBase64EncodedAttachmentsToIssueResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns1="http://soap.rpc.jira.atlassian.com">
      <addBase64EncodedAttachmentsToIssueReturn
      xsi:type="xsd:boolean">true</addBase64EncodedAttachmentsToIssueReturn>
      </ns1:addBase64EncodedAttachmentsToIssueResponse>
      </soapenv:Body>
      </soapenv:Envelope>
      ---------------------------------------------------------------

      The XML produced by the SOAP::Lite client is this:

      ----------------------------------------------------------------
      # CALL login
      <?xml version="1.0" encoding="UTF-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <login>
      <c-gensym3 xsi:type="xsd:string">soaptester</c-gensym3>
      <c-gensym5 xsi:type="xsd:string">soaptester</c-gensym5>
      </login>
      </soap:Body>
      </soap:Envelope>
      # RESPONSE
      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <loginResponse
      soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <loginReturn xsi:type="xsd:string">pX8Vpqp1Z8</loginReturn>
      </loginResponse>
      </soapenv:Body>
      </soapenv:Envelope>

      # CALL addBase64EncodedAttachmentsToIssue
      <?xml version="1.0" encoding="UTF-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body>
      <addBase64EncodedAttachmentsToIssue>
      <c-gensym8 xsi:type="xsd:string">pX8Vpqp1Z8</c-gensym8>
      <c-gensym10 xsi:type="xsd:string">TST-20616</c-gensym10>
      <soapenc:Array soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array">
      <item xsi:type="xsd:string">file1.txt</item>
      </soapenc:Array>
      <soapenc:Array soapenc:arrayType="xsd:string[1]" xsi:type="soapenc:Array">
      <item xsi:type="xsd:string">VGVzdCBmcm9tIEpJUkE6OkNsaWVudC4K
      </item>
      </soapenc:Array>
      </addBase64EncodedAttachmentsToIssue>
      </soap:Body>
      </soap:Envelope>
      # RESPONSE
      <?xml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <soapenv:Body>
      <soapenv:Fault>
      <faultcode>soapenv:Server.userException</faultcode>
      <faultstring>java.lang.ArrayStoreException:
      [Ljava.lang.String;</faultstring>
      <detail>
      <faultData xsi:type="ns1:ArrayStoreException" xmlns:ns1="http://lang.java"/>
      <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">atlassian14.managed.contegix.com</ns2:hostname>
      </detail>
      </soapenv:Fault>
      </soapenv:Body>
      </soapenv:Envelope>

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

      Can someone give me a hint?

      Thanks.

      Gustavo.
    • Gustavo Leite de Mendonça Chaves
      While my first message was waiting to be approved I was able to solve the problem and released version 0.23 of JIRA::Client at CPAN. The solution was to
      Message 2 of 2 , Dec 14, 2009
      View Source
      • 0 Attachment
        While my first message was waiting to be approved I was able to solve
        the problem and released version 0.23 of JIRA::Client at CPAN.

        The solution was to specify explicitly the names of the arrays and of
        their elements with calls to SOAP::Data::name.

        Thanks.

        Gustavo.
      Your message has been successfully submitted and would be delivered to recipients shortly.