× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I believe you need to encode "<" and "&" to make it plain text and not part
of the SOAP XML.

"<" should be "&lt;" and "&" should be "&amp;" (if I recall correctly).

/Thorbjørn

-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On
Behalf Of Jan Grove Vejlstrup
Sent: 18. september 2013 09:43
To: web400 Midrange
Subject: [WEB400] Passing a xml-string as parameter to a webservice

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:_P0RESUL
TAT>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiID8+IDxSZXN1bHRhdEtpczE0
dHJhIHZlcnNpb249IjEuMCI+IDxHZW5lcmF0aW9uVGltZXN0YW1wPjIwMTMtMDktMTZUMTQuNDAu
NDQ8L0dlbmVyYXRpb25UaW1lc3RhbXA+ICA8QmFzaXNEYXRlbj4gPEZpcm1hPjAxPC9GaXJtYT4g
PEV4dGVybmVLdW5kZW5OdW1tZXI+OTg1Njc1PC9FeHRlcm5lS3VuZGVuTnVtbWVyPiA8TFRDb2Rl
PkE8L0xUQ29kZT4gPFZlcmthdWZzc3RlbGxlPjAyPC9WZXJrYXVmc3N0ZWxsZT4gPFdlcms+MTAw
PC9XZXJrPiA8QW56YWhsRGV0YWlsUG9zaXRpb25lbj4xMDwvQW56YWhsRGV0YWlsUG9zaXRpb25l
bj4gPC9CYXNpc0RhdGVuPiA8VHJhbnNwb3J0S29zdGVuPjEyMzQuNTY8L1RyYW5zcG9ydEtvc3Rl
bj4gIDwvUmVzdWx0YXRLaXMxNHRyYT4gIA==</ns:_P0RESULTAT></ns:return></ns:kis14t
raResponse></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?

Best regards

Jan


--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list To post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.