Call services with 2 different operation

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
Cinzia
Posts: 9
Joined: Fri Dec 01, 2023 11:48 am

Call services with 2 different operation

Post by Cinzia »

Hi everyone!
I need to call a SOAP service from an RPGLE program.
By verifying the call with SOAPUI the endpoint responds correctly while from AS400 it does not.
I already call other services without problems but I see that there is a difference if I look at the SOAPUI and that is that I have 2 different operation.
Could this be the problem?

My call is as follows:

http_setOption('SoapAction': '""') ;
http_stmf('POST':URL:%Trim(IFSRcv):%Trim(IFSSnd):'text/xml');

What do I need to change to specify which operation to use?

thanks so much for the help
Cinzia
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Call services with 2 different operation

Post by Scott Klement »

Hi Cinzia,

What is meant when you say "I have 2 different operation". Which part are you referring to by "operation"? Are there any other differences?
Cinzia
Posts: 9
Joined: Fri Dec 01, 2023 11:48 am

Re: Call services with 2 different operation

Post by Cinzia »

Hi Scott,
In the image file (1) I have the Login endpoint which contains the single login operation which I recall without problems.
In the image file instead I have the cargo endpoint which contains the Get and Set operations.
Recalling this endpoint on the AS400 side gives me an error while on the soap side it works correctly.
I need to invoke the Set operation.
How should I set up the call?

Thank you very much for your attention
Cinzia
immagine (1).png
immagine (1).png (5.25 KiB) Viewed 69669 times
immagine.png
immagine.png (6.83 KiB) Viewed 69669 times
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Call services with 2 different operation

Post by Scott Klement »

In SoapUI, you can name operations anything you wish. These names are just for your documentation purposes, they are not used in the underlying implementation.

You should click into the request of the operation and see what it's doing. What HTTP method, what message it's sending, what credentials it's using, any attachments it's providing, etc. This is the information you'll need within HTTPAPI.
Cinzia
Posts: 9
Joined: Fri Dec 01, 2023 11:48 am

Re: Call services with 2 different operation

Post by Cinzia »

Hi Scott,
thanks for the reply but unfortunately I still can't understand how to configure the call at AS400 level.
I attach all the properties I have available.
For the SOAPAction I inserted the following instruction:

http_setOption('SoapAction': '"https://xxx/services/cargo"');

but to set the Operation? How do I set the Operation to Set as in my case?

Where can I see if SOAP makes a call with the POST method or something else?

sorry and thanks
Cinzia
Operation Properties.png
Operation Properties.png (29.39 KiB) Viewed 69642 times
Request Properties 1.png
Request Properties 1.png (41.76 KiB) Viewed 69642 times
Request Properties 2.png
Request Properties 2.png (43.23 KiB) Viewed 69642 times
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Call services with 2 different operation

Post by Scott Klement »

Cinzia wrote: Thu Dec 07, 2023 8:25 am Hi Scott,
thanks for the reply but unfortunately I still can't understand how to configure the call at AS400 level.
I attach all the properties I have available.
The AS/400 was discontinued 23 (almost 24) years ago. Please don't call your server running IBM i that anymore.
Cinzia wrote: Thu Dec 07, 2023 8:25 am For the SOAPAction I inserted the following instruction:

http_setOption('SoapAction': '"https://xxx/services/cargo"');
This is the correct way to set the SOAPAction.
Cinzia wrote: Thu Dec 07, 2023 8:25 am but to set the Operation? How do I set the Operation to Set as in my case?
The "operation" you see in SoapUI is only in SoapUI, it is not sent over the network, and is not part of the actual process.. it is ONLY for documentation purposes. There is no need to set it. If you must have it in your RPG program, make it a comment, since it is only used for documentation.
Cinzia wrote: Thu Dec 07, 2023 8:25 am Where can I see if SOAP makes a call with the POST method or something else?
SOAP, basically, always uses POST. (Technically, according to the specs, it can also use GET -- but it's not practical in the real world because SOAP messages are too complex.)

To find out for certain, in SoapUI do the following:
  1. Click the "submit request" button (looks like a green triangle -- like a "play" button for playing music.)
  2. After the request completes, click the "Raw" tab on the left.
  3. At the start of the raw data, it should show "POST" followed by your URL. (or GET if it's a GET request)
If possible, consider using a REST API instead of SOAP. Not many people are still using SOAP today -- it has been on the decline since 2004.
Cinzia
Posts: 9
Joined: Fri Dec 01, 2023 11:48 am

Re: Call services with 2 different operation

Post by Cinzia »

Hi Scott,
thanks for the reply

in SOAPUI I see this information:

POST https://xxx.xxx.eu/xxxxxxcargo/services/cargo HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "https://xxxx.xxxx.eu/xxxxs/cargo"
Content-Length: 4011
Host: xxx.xxxx.eu
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.5 (Java/16.0.1)

in Http_debug after call in IBM I see this information:
HTTPAPI Ver 1.45 released 2021-09-20
NTLM Ver 1.4.0 released 2014-12-22
OS/400 Ver V7R4M0

http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry : 2
DNS resolver options: x'00000136'
DNS default domain: SXXX.COM
DNS server found: 10.xxx.199.12
DNS server found: 10.xxx.199.13
Nagle's algorithm (TCP_NODELAY) disabled.
SNI hostname set to: xxx.xxx.eu
--------------------------------------------------------
Dump of server-side certificate information:
--------------------------------------------------------
Cert Validation Code = 6000
-----BEGIN CERTIFICATE--
MIIG7DCCBdSgAwIBAgIQB0+e ecc....


http_long_ParseURL(): entered
do_oper(POST): entered
There are 0 cookies in the cache
POST /xxx/xxs/cargo HTTP/1.1
Host: apidevextra.seamilano.eu
User-Agent: http-api/1.45
Content-Type: text/xml; charset=UTF-8
SOAPAction: "https://xxx.xxx.eu/services/cargo"
Content-Length: 58749


sendraw(): entered
Lo§ @¥ ¢ ~ ñKð @ ~ ¤£ `ø on@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
%L¢ ¥zÅ ¥ @§ ¢z¢ ¥~ ££ zaa¢ ¢K§ ¢ K a¢ a ¥

recvresp(): entered
HTTP/1.1 500 Internal Server Error
Date: Mon, 11 Dec 2023 11:06:49 GMT
Server:
Connection: close
X-CorrelationID: Id-49ed7665042e14bc134515c2 0
Content-Type: text/xml; charset="utf-8"


SetError() £13: HTTP/1.1 500 Internal Server Error
recvresp(): end with 500
recvdoc parms: identity 0
header_load_cookies() entered
recvdoc(): entered
SetError() £0:
recvdoc(): No content-length: receiving until disconnect
<?xml version="1.0" encoding="UTF-8"?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header>
SetError() £44: CommTCP_read: Socket has been shut down.
SetError() £13: HTTP/1.1 500 Internal Server Error
http_close(): entered


So if the call at this point would seem correct, how come I don't have the same result, the error is always 500? Do I have to enter parameters to the call? Encoding? Do you have any suggestions?
Thank you for your support
Scott Klement
Site Admin
Posts: 658
Joined: Sun Jul 04, 2021 5:12 am

Re: Call services with 2 different operation

Post by Scott Klement »

Hmm, it seems that the data you're sending is coming across as garbage.

When you posted your RPG code at the start of this discussion thread, you showed us that you were using http_stmf() to send your data from a file. Is it possible that you accidentally created the file in EBCDIC?
Cinzia
Posts: 9
Joined: Fri Dec 01, 2023 11:48 am

Re: Call services with 2 different operation

Post by Cinzia »

Thanks Scott, found the problem ;) , changing the CSID of the XML file to 1208 (UTF-8).
Thank you for your support and see you soon

Cinzia
Post Reply