[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: HTTPAPI - Passing XML-file as Parameter to a WebService
You included much information and it all looks pretty good. But you didn't include the debug file that will tell you if you are sending the data or not (which it appears you are). If you are sending the data according to the debug file but the web service is not seeing it, then you are left with some kind of de-coding problem on the web server.
The web service has a log?
Can you see the raw data coming in and what it is doing to the data?
Can you run debug on the web service?
-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Thomas Raddatz
Sent: Wednesday, September 25, 2013 1:08 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: HTTPAPI - Passing XML-file as Parameter to a WebService
Jan,
My best bet is that you need to encode "xmlInput" properly before you
assign it to element <_P0XMLINPUT>. For example "<" should be encoded to
"<".
The way you do it works only for elements of type "xsd:any". "any" means
that the element can contain any other valid XML elements. But in your case
I assume that "_P0XMLINPUT" is of type "xsd:string" which requires proper
encoding of XML entities.
Feel free to check the following links:
http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
http://coderstoolbox.net/string/#!encoding=xml&action=encode&charset=us_ascii
Thomas.
Am 17.09.2013 11:36, schrieb Jan Grove Vejlstrup:
> Hello,
>
> I have a Webservice with this wsdl:
>
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://kis14tra.wsbeans.iseries/xsd">
> <soapenv:Header/>
> <soapenv:Body>
> <xsd:kis14tra>
> <xsd:args0>
> <xsd:_P0RESULTAT>?</xsd:_P0RESULTAT>
> <xsd:_P0XMLINPUT>?</xsd:_P0XMLINPUT>
> </xsd:args0>
> </xsd:kis14tra>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I use the Integrated Webservice (IWS) to implement the Service. As
> P0XMLINPUT I want to pass this XML as a string:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <Transportimport ISHOP="9XX">
> <Kunde Nummer="9893" NummerERP="373049" />
> <Pos>
> <ExterneArtikelNr>111246</ExterneArtikelNr>
> <Farbe>111</Farbe>
> <Ausfuehrung>183</Ausfuehrung>
> <Menge>1</Menge>
> </Pos>
> <Pos>
> <ExterneArtikelNr>347213</ExterneArtikelNr>
> <Farbe>100</Farbe>
> <Ausfuehrung>184</Ausfuehrung>
> <Menge>1</Menge>
> </Pos>
> </Transportimport>
>
> I use this program and HTTPAPI to test the webservice:
>
> H bnddir('HTTPAPI')
> H copyright('(c) 2013 WEMAG Consulting AG, CH-3122 Kehrsatz')
>
> *
> W*E CRTRPGMOD kis144 srcfile(*libl/qrpglesrc)
> W*E+ DBGVIEW(*SOURCE)
> W*E+ REPLACE(*YES)
> W*E CRTPGM kis144 bndsrvpgm(qsysdir/qaxis10ht) actgrp(*new)
> W*E+ REPLACE(*YES)
> W*E DLTMOD kis144
> E*W
>
> *
> /copy HTTPAPI_H
>
> /copy apr_b64_h
> /copy iconv_h
> /copy ifsio_h
> /copy errno_h
>
> D genIconvTable PR
> D fromCCSID 10i 0 const
> D toCCSID 10i 0 const
>
> D convertString PR 65502a varying
> D String 65502a const varying options(*varsize)
>
> D MapXmlData PR
> d resultText 32760a
> d depth 10i 0
> d name 1024a varying const
> d path 24576a varying const
> d value 65535a varying const
> d attrs * dim(32767)
> d const options(*varsize)
>
> d kis144 PR ExtPgm('KIS144')
> d kis144 PI
> d VARYINGDATAOFFSET...
> d c const(2)
> D VARPREF C 2
> d ifsPathDec s 100a varying
> d fd s 10i 0
> d err s 10i 0
>
> d msg s 52a varying
> d SOAP s 1024a varying
> d rc s 10i 0
> d len s 10i 0
> d xmlInput s 32765a
>
> d sizeEnc s 20i 0
> d resultText s 32760a
> d decdata s 32760a
> d encdata s 32760a
> d encdata1 s 32760a
> d decdata1 s 32760a
> d enclen s 10i 0
> d declen s 10i 0
>
> d table ds likeds(iconv_t)
>
> /free
>
> *inlr = *on;
>
> ifsPathDec = '/jgvtmp/Kis14TraDecUtf02a.xml';
>
> // xmlInput = 'iejnppuuttXmL09';
> xmlInput = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
> + ' <Transportimport ISHOP="9XX">'
> + ' <Kunde Nummer="9893" NummerERP="373049" FirmaERP="50" />'
> + ' <Pos>'
> + ' <ExterneArtikelNr>111246</ExterneArtikelNr>'
> + ' <Farbe>111</Farbe>'
> + ' <Ausfuehrung>183</Ausfuehrung>'
> + ' <Menge>1</Menge>'
> + ' </Pos>'
> + ' <Pos>'
> + ' <ExterneArtikelNr>347213</ExterneArtikelNr>'
> + ' <Farbe>100</Farbe>'
> + ' <Ausfuehrung>184</Ausfuehrung>'
> + ' <Menge>1</Menge>'
> + ' </Pos>'
> + ' </Transportimport>';
>
>
> SOAP= '<soapenv:Envelope xmlns:soapenv='
> + '"http://schemas.xmlsoap.org/soap/envelope/"'
> + ' xmlns:xsd="http://kis14tra.wsbeans.iseries/xsd">'
> + ' <soapenv:Header/>'
> + ' <soapenv:Body>'
> + ' <xsd:kis14tra>'
> + ' <xsd:args0>'
> + ' <xsd:_P0RESULTAT/>'
> + ' <xsd:_P0XMLINPUT>' + %trim(xmlInput)
> + ' </xsd:_P0XMLINPUT>'
> + ' </xsd:args0>'
> + ' </xsd:kis14tra>'
> + ' </soapenv:Body>'
> + '</soapenv:Envelope>';
>
> len = %len(SOAP);
> msg = 'len *' + %char(len) + '*';
> dsply msg;
>
> // http_setCCSIDs(1208 : 0); **************
> http_debug(*ON: '/jgvtmp/kis14TraDebug.txt');
>
> rc = http_post_xml('http://chwemag1:10010/web/services/KIS14TRA'
> : %addr(SOAP) + VARYINGDATAOFFSET
> : %len(SOAP)
> : *NULL
> : %paddr(MapXmlData)
> : %addr(resultText)
> : HTTP_TIMEOUT
> : HTTP_USERAGENT
> : 'text/xml; charset=UTF-8'
> : 'urn.kis14tra');
>
> if (rc <> 1);
> http_crash();
> endif;
>
> msg = 'rText*' + %subst(resultText: 1: 30) + '*end';
> dsply msg;
> encdata = resultText;
> msg = 'enclen*' + %char(%len(encdata)) + '*';
> dsply msg;
>
> declen = apr_base64_decode_binary(decdata
> : encData);
> msg = 'declen *' + %char(declen) + '*';
> dsply msg;
> genIconvTable(1208: 500); // convert utf-8 -> EBCDIC
> decdata = convertString(decdata);
> iconv_close(table);
> msg = 'dText*' + %subst(decdata: 1: 30) + '*end';
> dsply msg;
>
> unlink(ifsPathDec);
> fd = open(ifsPathDec
> : O_CREAT+O_WRONLY+O_TEXTDATA+O_TEXT_CREAT+O_CCSID
> : S_IWUSR+S_IRUSR+S_IRGRP+S_IROTH
> : 1208: 0);
> if fd < 0;
> die('openDec(): '+%str(strerror(errno)));
> return;
> endif;
> callp write(fd: %addr(decdata): declen);
> callp close (fd);
>
> return;
>
> /end-free
>
> P MapXmlData B
> D MapXmlData PI
> d resultText 32760a
> d depth 10i 0
> d name 1024a varying const
> d path 24576a varying const
> d value 65535a varying const
> d attrs * dim(32767)
> d const options(*varsize)
> /free
>
> if (name='ns:_P0RESULTAT');
> resultText = %trim(value);
> endif;
> /end-free
> P MapXmlData E
>
>
> *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> * genIconvTable
> *
> * peFromCCSID
> * peToCCSID
> *
> *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> P genIconvTable B
> d PI
> d peFromCCSID 10i 0 const
> d peToCCSID 10i 0 const
>
> d i s 10i 0
>
> D from ds likeds(QtqCode_T)
> D inz(*LIKEDS)
> D to ds likeds(QtqCode_T)
> D inz(*LIKEDS)
> D errMsg s 50A varying
> *
> /free
>
> from.CCSID = peFromCCSID;
> to.CCSID = peToCCSID;
>
> table = QtqIconvOpen(to: from);
> if (table.return_value = -1);
> ReportError();
> endif;
>
> return;
>
> /end-free
> P genIconvTable E
>
> *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> * convertString
> *
> * peString String to be converted
> *
> * result is the converted string
> *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> P convertString B
> d PI 65502a varying
> d peString 65502a const varying options(*varsize)
>
>
> D VARPREF C 2
>
> D p_input s *
> D inleft s 10U 0
> D p_output s *
> D outleft s 10U 0
> D len s 10U 0
>
> D input_data s 65502a varying
> D output_data s 65502a varying
>
> *
> /free
>
> input_data = peString;
> %len(output_data) = %size(output_data) - VARPREF;
>
> p_input = %addr(input_data) + VARPREF;
> inleft = %len(input_data);
>
> p_output = %addr(output_data) + VARPREF;
> outleft = %len(output_data);
>
> iconv( table
> : p_input
> : inleft
> : p_output
> : outleft );
>
> %len(output_data) = %len(output_data) - outleft;
> len = %len(output_data);
>
>
> return output_data;
>
> /end-free
> P convertString E
>
> /DEFINE ERRNO_LOAD_PROCEDURE
> /COPY ERRNO_H
>
> My problem is, that the input parameter is empty, when it reaches the
> webservice.
>
> If I use the test-function, that comes with the IWS
> (chwemag1:2001/HTTPAdmin) the service works all-right:
> <soapenv:Envelope><soapenv:Body><q0:kis14tra><q0:args0><q0:_P0RESULTAT/><q0:_P0XMLINPUT><?xml
> version="1.0" encoding="UTF-8" standalone="yes"?> <Transportimport
> ISHOP="9XX"> <Kunde Nummer="9893" NummerERP="373049" /> <Pos>
> <ExterneArtikelNr>111246</ExterneArtikelNr> <Farbe>111</Farbe>
> <Ausfuehrung>183</Ausfuehrung> <Menge>1</Menge> </Pos> <Pos>
> <ExterneArtikelNr>347213</ExterneArtikelNr> <Farbe>100</Farbe>
> <Ausfuehrung>184</Ausfuehrung> <Menge>1</Menge> </Pos>
> </Transportimport></q0:_P0XMLINPUT></q0:args0></q0:kis14tra></soapenv:Body></soapenv:Envelope>
>
>
> Result:
>
>
> <soapenv:Envelope><soapenv:Body><ns:kis14traResponse><ns:return><ns:_P0RESULTAT>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+IDxSZXN1bHRhdEtpczE0dHJhIHZlcnNpb249IjEuMCI+IDxHZW5lcmF0aW9uVGltZXN0YW1wPjIwMTMtMDktMTZUMTQuNDAuNDQ8L0dlbmVyYXRpb25UaW1lc3RhbXA+ICA8QmFzaXNEYXRlbj4gPEZpcm1hPjAxPC9GaXJtYT4gPEV4dGVybmVLdW5kZW5OdW1tZXI+OTg1Njc1PC9FeHRlcm5lS3VuZGVuTnVtbWVyPiA8TFRDb2RlPkE8L0xUQ29kZT4gPFZlcmthdWZzc3RlbGxlPjAyPC9WZXJrYXVmc3N0ZWxsZT4gPFdlcms+MTAwPC9XZXJrPiA8QW56YWhsRGV0YWlsUG9zaXRpb25lbj4xMDwvQW56YWhsRGV0YWlsUG9zaXRpb25lbj4gPC9CYXNpc0RhdGVuPiA8VHJhbnNwb3J0S29zdGVuPjEyMzQuNTY8L1RyYW5zcG9ydEtvc3Rlbj4gIDwvUmVzdWx0YXRLaXMxNHRyYT4gIA==</ns:_P0RESULTAT></ns:return></ns:kis14traResponse></soapenv:Body></soapenv:Envelope>
>
>
>
>
> If I use just a simple text-string as input, it works fine too. It looks
> like the XML-file is the problem.
>
> What do I do wrong? Can I user another http-function or other parameters?
>
> Best regards
>
> Jan
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list. To unsubscribe, please go to:
> 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
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------