[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending Attachment in WSDL2RPG



   Thomas,
   I have successfully used the MTOM version - there were several
   corrections I needed, but your explanation got me there. Thank you! I
   did spend some time first trying to get the "no MTOM" option working,
   each time had an empty file. I'm sure it was something in my code.
   Moving on.
   Jim Franz�
   On Sun, Oct 16, 2016 at 4:48 AM, Thomas Raddatz
   <[1]thomas.raddatz@xxxxxxxxxxx> wrote:

     Jim,
     The 500 error is because my test web service does not understand
     MTOM
     messages. So that error is an expected error.
     "is the 3rd line with ".contentMTOM" my problem?"
     I cannot answer that question, because the "contentMTOM" parameter
     is
     not related to the SOAP message format. It is specific to your web
     service and actually the developer could have called it "fooBaa".
     What I
     want to say is, that WSDL2RPG is not aware of that parameter. You
     have
     to look at the documentation of the web service to understand what
     it is
     used for.
     What does your request message look like (from your debug log)? Is
     it
     similar to my "MTOM_on" or "MTOM_off" message. Look at the "type"
     attribute of the "ContentType" header to answer that question or,
     even
     better, post the debug log or send me a private message with the
     debug log.
     MTOM off:
     Content-Type: multipart/related;
     � � � � type="application/soap+xml";
     � � � � boundary="MIMEBoundary_20161015161722957000_835444";
     � � � � start="<[2]254BE006E6C519E1A5DC00
     04AC1AF51A.2@xxxxxxxxxxx>"
     MTOM on:
     Content-Type: multipart/related;
     � � � � type="application/xop+xml";
     � � � � boundary="MIMEBoundary_20161015161801100000_835444";
     � � � � start="<[3]6ABEC006E6C719E1A5DC00
     04AC1AF51A.2@xxxxxxxxxxx>"
     Here are my ideas what you have to do next:
     a) Figure out what message type you send (MTOM or not).
     b) Figure out what the web service really wants (MTOM or not).
     Because
     of element "contentMTOM", I would assume an MTOM message.
     c) Figure out, whether or not the soap message must contain a
     reference
     to the file attachment like this:
     Start of the file attachment. The attribute of interest is
     "Content-ID".
     --MIMEBoundary_20160509183854394000_558036
     Content-Type: application/zip;
     � � � � name="Scont_20160101_20160131.zip"
     Content-Transfer-Encoding: binary
     Content-ID: <[4]A56940016BE319D5B0040004AC0C3458.1@xxxxxxxxxxx>
     Content-Disposition: attachment;
     � � � � filename="Scont_20160101_20160131.zip"
     Maybe, that you have to put it somewhere in the soap message to let
     the
     receiver know the attachment that belongs to the message like this:
     <documento>
     � �<inc:Include
     � � href="[5]cid:A56940016BE319D5B0040004AC0C3458.1@tools400.de"
     � � xmlns:inc="[6]http://www.w3.org/2004/08/xop/include"/>
     </documento>
     For a) look at the Content-Type header.
     For b) and c) ask your web service provider or look at the
     documentation
     of the web service. An example message would be great to answer b)
     and c).
     Can you use soapUI to call the web service? Can it successfully call
     the
     service?
     Thomas.

   Am 16.10.2016 um 04:35 schrieb midrange:
   > Thomas,
   >
   > Reading the logs you sent, the MTOM "on" log shows a http 500 error
   and did not complete the attachment processing (see end of this post).
   >
   > I am going back through how I generated the programs to give you more
   info.
   > I am currently not authorized to save the wsdl2rpg lib and zip to you
   for analysis (developers can't save/export anything).
   > Most of the source has 8/24/16 change dates, and I downloaded on
   9/19/16 There was a previous version 1.16.4 library I renamed before
   new install and was not in libl
   >
   > LIBHTTP is 1.32� and installed same day (first) There was a prev
   version 1.29 and renamed before new install System at ptf cume 15142
   (...).
   > > I will be first to admit working in ILE is a challenge to me so
   pardon my ignorance - This is part of the generated test program - is
   the 3rd line with ".contentMTOM" my problem? Should it be commented
   out? I only modified filename and mimeType
   >
   > // Clear array item
   > clear parameters.document.contentList.content(X_A2);
   >
   > // Set array item values:
   > parameters.document.contentList.content(X_A2).content = 'base64';
   parameters.document.contentList.content(X_A2).contentMTOM = 'base64+ ';
   parameters.document.contentList.content(X_A2).fileName =
   %trim(j2FILEPATH); parameters.document.contentList.content(X_A2).
   mimeType = %trim(j2MIMETYPE);
   >
   > ... required parameters to send with document
   >
   > // Create attachments
   > j3transferEnc = 'WSDL_MIME_BASE64';
   > j3suggFileNam = %trim(j2DOCTITLE);
   > j3filePath� � = %trim(j2FILEPATH);
   > j3mimeType� � = %trim(j2MIMETYPE);
   >
   > partID =
   >� � P8ServiceImplPort_addDocument_Attachments_addFile(
   >� � � �j3filePath: j3mimeType
   >� � � �: j3transferEnc: j3suggFileNam);
   >
   >
   > // Now let's call the web service.
   > addDocumentResponse =
   >� � P8ServiceImplPort_addDocument(
   >� � � � parameters:
   >� � � � errText);
   >
   >
   >
   > Jim Franz
   >
   > MTOM "on" log you sent
   >
   > SetError() #13: HTTP/1.1 500 Internal Server Error
   > recvresp(): end with 500
   > recvdoc parms: chunked 0
   > header_load_cookies() entered
   > recvchunk(): entered
   > get_chunk_size(): entered
   > 257
   >
   > chunk size = 599
   > get_chunk_size returned 599
   > calling comm_blockread
   > <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope
   xmlns:soapenv="[7]http://www.w3.org/2003/05/soap-envelope";><
   soapenv:Header xmlns:wsa="[8]http://www.w3.org/
   2005/08/addressing"><wsa:Action>[9]http://www.w3.org/2005/
   08/addressing/soap/fault</wsa:Action></soapenv:Header><
   soapenv:Body><soapenv:Fault><soapenv:Code><soapenv:Value>
   soapenv:VersionMismatch</soapenv:Value></soapenv:Code><
   soapenv:Reason><soapenv:Text xml:lang="en-US">Transport level
   information does not match with SOAP Message namespace
   URI</soapenv:Text></soapenv:Reason><soapenv:Detail
   /></soapenv:Fault></soapenv:Body></soapenv:Envelope>
   > comm_blockread returned 599
   > ** [10]2016-10-15-16.18.01.702000: Preparing to parse received
   message
   > WSDL2RPG: USR0042: Unexpected Soap element received from web service.
   >� � � � � � � � � � Cause . . . . . :� �The web service
   sent an element that was not expected. This error often happens if the
   web service sends a Soap header that has not been declared in the wsdl
   file. Please enable the debug log to see what actually was
   > returned by the web service. Most likely you then want to disable
   sending this escape message in procedures 'SOAPMessage_
   unexpectedElementStart' and 'SOAPMessage_unexpectedElementEnd'.
   >� � � � � �received from procedure: BASICS1R1_f_sndPgmMsg
   >� � � � � � � � � � �and statement: 54400 WSDL2RPG (eXpat
   error): (-1009) Unexpected Soap element received from web service.
   >
   >� � �received at line: 1
   >� � � � � � at column: 177
   >� � � �from procedure: WSDL2R97_XMLSAXParser_parse
   >� � � � and statement: 107600
   > ** 2016-10-15-16.18.01.729000: Failed parsing XML message
   > ** 2016-10-15-16.18.01.729000: Failed parsing XML message
   > SetError() #16: recvchunk: saveproc: Not all data was written�   > http_close(): entered
   > HTTPAPI Ver 1.33-BETA2 released 2016-10-13 NTLM Ver 1.4.0 released
   2014-12-22
   > OS/400 Ver V7R2M0
   >
   > ** 2016-10-15-16.18.01.730000: Leaving DownloadAttachment12_
   setAttachment()
   >
   >
   > -----Original Message-----
   > From: [11]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
   [mailto:[12]ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Thomas
   Raddatz
   > Sent: Saturday, October 15, 2016 10:34 AM
   > To: HTTPAPI and FTPAPI Projects
   > Subject: Re: Sending Attachment in WSDL2RPG
   >
   > I have no idea, why it should not work for you. I tested MTOM support
   again and I could switch MTOM on and off by the debugger. Please find
   the example logs attached.
   >
   > Just to make sure: Did you properly compile the "WS_OPER" module and
   link the stub service program? Maybe you should try to debug procedure
   > MessageContext_new() of moduleWSDL2R85 of service program WSDL2RPGRT
   and change "isMTOM" there.
   >
   > I also do not understand why MTOM should be the default. For sure it
   is not the default value.
   >
   > Maybe you should send to me the source members that you generated
   with WSDL2RPG and the zip file of your version of WSDL2RPG.
   >
   > PM: thomas dot raddatz at tools400 dot de
   >
   > Thomas.
   >
   > Am 14.10.2016 um 17:41 schrieb Jim Franz:
   >>� � Thanks for the info - file got there, but they could not handle
   >>� � using� MTOM - the 1.16.5beta3 seems to default it� and I
   can't see how
   >>� � to not use it. They asked I not use MTOM..
   >>� � Jim
   >>
   >>� � On Fri, Oct 14, 2016 at 4:41 AM, Thomas Raddatz
   >>� � <[1][13]thomas.raddatz@xxxxxx> wrote:
   >>
   >>� � � Jim,
   >>� � � Actually WSDL2RPG should automatically create a MIME
   message, as
   >>� � � soon as you called * _Attachments_addFile() to add a file as
   an
   >>� � � attachment to the soap request message.
   >>� � � For example:
   >>� � � // Attach file to request message.
   >>� � � DownloadAttachment12_setAttachment_Attachments_addFile(
   >>� � � � � �path: 'text/plain': WSDL_MIME_BINARY);
   >>� � � // Set the parameter values of the request message
   >>� � � // of the web service.
   >>� � � //� � � assign values here
   >>� � � requestMessage.fileName = path;
   >>� � � // Now let's call the web service.
   >>� � � setAttachmentResponse =
   >>� � � � � �DownloadAttachment12_setAttachment(
   >>� � � � � � � � �requestMessage:
   >>� � � � � � � � �errText);
   >>� � � Please check the debug log, whether or not WSDL2RPG created
   a MIME
   >>� � � message. A MIME starts with:
   >>� � � MIME-Version: 1.0
   >>� � � Content-Type: multipart/related;
   >>� � � � � � � � � type="application/soap+xml";
   >>� � � � � � � � � boundary="MIMEBoundary_
   20161014102651910000_791705";
   >>� � � � � � � � � start="<[2]C1648006CDC119E1A5DC00
   >>� � � [14]04AC1AF51A.2@xxxxxxxxxxx>"
   >>� � � Each attachment is separte by a "mime boundary", which looks
   like
   >>� � � this:
   >>� � � sendraw(): entered
   >>� � � --MIMEBoundary_20161014102651910000_791705
   >>� � � Content-Type: application/soap+xml;
   action="[3][15]http://tools400.de/
   >>� � � wsdl2rpg/webservice/sample/downloadattachment/service/
   setAttachment"
   >>� � � Content-Transfer-Encoding: binary
   >>� � � Content-ID: <[4][16]C1648006CDC119E1A5DC0004AC
   1AF51A.2@xxxxxxxxxxx>
   >>� � � <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope
   >>� � � xmlns:soapenv="[5][17]http://www.
   w3.org/2003/05/soap-envelope"
   >>� � � xmlns:tns="[6][18]http://tools400.
   de/wsdl2rpg/webservice/sample/
   >>� � � downloadattachment/service"><soapenv:Body><tns:
   >>� � � setAttachmentRequest><fileName>Hello
   World.txt</fileName></tns:
   >>� � � setAttachmentRequest></soapenv:Body></soapenv:Envelope>
   >>� � � --MIMEBoundary_20161014102651910000_791705
   >>� � � Content-Type: text/plain;
   >>� � � � � � � � � name="Hello World.txt"
   >>� � � Content-Transfer-Encoding: binary
   >>� � � Content-ID: <[7][19]C1099006CDC119E1A5DC0004AC
   1AF51A.1@xxxxxxxxxxx>
   >>� � � Hello World!
   >>� � � --MIMEBoundary_20161014102651910000_791705--
   >>� � � Thomas
   >

   > ------------------------------------------------------------
   -----------
   > This is the FTPAPI mailing list.� To unsubscribe, please go to:
   > [20]http://www.scottklement.com/mailman/listinfo/ftpapi
   > ------------------------------------------------------------
   -----------
   >
   -----------------------------------------------------------------------
   This is the FTPAPI mailing list.� To unsubscribe, please go to:
   [21]http://www.scottklement.com/mailman/listinfo/ftpapi
   -----------------------------------------------------------------------

References

   1. mailto:thomas.raddatz@xxxxxxxxxxx
   2. mailto:254BE006E6C519E1A5DC0004AC1AF51A.2@xxxxxxxxxxx
   3. mailto:6ABEC006E6C719E1A5DC0004AC1AF51A.2@xxxxxxxxxxx
   4. mailto:A56940016BE319D5B0040004AC0C3458.1@xxxxxxxxxxx
   5. mailto:cid%3AA56940016BE319D5B0040004AC0C3458.1@xxxxxxxxxxx
   6. http://www.w3.org/2004/08/xop/include
   7. http://www.w3.org/2003/05/soap-envelope
   8. http://www.w3.org/2005/08/addressing
   9. http://www.w3.org/2005/08/addressing/soap/fault
  10. tel:2016-10-15-16
  11. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  12. mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
  13. mailto:thomas.raddatz@xxxxxx
  14. mailto:04AC1AF51A.2@xxxxxxxxxxx
  15. http://tools400.de/
  16. mailto:C1648006CDC119E1A5DC0004AC1AF51A.2@xxxxxxxxxxx
  17. http://www.w3.org/2003/05/soap-envelope
  18. http://tools400.de/wsdl2rpg/webservice/sample/
  19. mailto:C1099006CDC119E1A5DC0004AC1AF51A.1@xxxxxxxxxxx
  20. http://www.scottklement.com/mailman/listinfo/ftpapi
  21. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------