Unespected response

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
ANDREA.P
Posts: 3
Joined: Wed Nov 24, 2021 9:18 am

Unespected response

Post by ANDREA.P »

Hi everybody,
I can't get a valid response from a machine equipped with a soap interface to my IBM i.
The HTTPAPI version is 1.38 dated 2017-10-09
The OS version is 7.2
The request with the utility SOAPUI works fine, here's the expected response.

Code: Select all

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <LeggiResponse xmlns="http://tempuri.org/">
         <LeggiResult xmlns:a="http://schemas.datacontract.org/2004/07/RusconiELineWS" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:ContatoreTot2>2343</a:ContatoreTot2>
            <a:HMI_CaricoTotaleUSSS>7950</a:HMI_CaricoTotaleUSSS>
            <a:HMI_Ticket_in_lavorazione/>
            <a:HMI_USSS_LOWER_Average>60.8333321</a:HMI_USSS_LOWER_Average>
            <a:HMI_USSS_UPPER_Average>236.306656</a:HMI_USSS_UPPER_Average>
            <a:ImpNumCicli>1</a:ImpNumCicli>
            <a:PassoImpostatoUTAS>855</a:PassoImpostatoUTAS>
            <a:QtaBusteProdotte>0</a:QtaBusteProdotte>
            <a:RiscSInfTmpDesiderata>30</a:RiscSInfTmpDesiderata>
            <a:RiscSSupTmpDesiderata>230</a:RiscSSupTmpDesiderata>
            <a:SetPointUSSS>8000</a:SetPointUSSS>
            <a:TempoSaldaturaUSSS>0.8</a:TempoSaldaturaUSSS>
            <a:TempoTrainoAnt>0.7</a:TempoTrainoAnt>
         </LeggiResult>
      </LeggiResponse>
   </s:Body>
</s:Envelope>
I wrote a simple program to test it.

Code: Select all

       ctl-opt DECEDIT('0,')
               datedit(*dmy) datfmt(*iso)
               option(*nodebugio) bnddir('HTTPAPI');
      //
       DCL-S url              VARCHAR(100);
       DCL-S soap             VARCHAR(1000);
       DCL-S response         VARCHAR(100000);
      /copy httpapi_h
       http_debug(*On:'/tmp/mydebuglog.txt');
       //
         http_setOption('SoapAction': '"GetValue"');
         //
         url = 'http://192.168.15.41:8733/+
         Design_Time_Addresses/RusconiELineWS/Service1/';
         soap = '<?xml version="1.0" encoding="utf-8"?>  +
           <soapenv:Envelope +
             xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" +
             xmlns:tem="http://tempuri.org/"> +
             <soapenv:Header/> +
             <soapenv:Body> +
             <tem:Leggi/> +
             </soapenv:Body> +
             </soapenv:Envelope>';
         //
         response = http_string( 'GET' : url : SOAP : 'text/xml');
         *inlr = *on;
         RETURN;
Here's the log i get.

Code: Select all

HTTPAPI Ver 1.38 released 2017-10-09
NTLM Ver 1.4.0 released 2014-12-22
OS/400 Ver V7R2M0

New iconv() objects set, PostRem=819. PostLoc=0. ProtRem=819. ProtLoc=0
http_persist_open(): entered
http_long_ParseURL(): entered
DNS resolver retrans: 2
DNS resolver retry  : 2
DNS resolver options: x'00000136'
DNS default domain: EURONDA.COM
DNS server found: 192.168.1.11
DNS server found: 192.168.1.12
Nagle's algorithm (TCP_NODELAY) disabled.
http_persist_req(GET) entered.
http_long_ParseURL(): entered
http_long_ParseURL(): entered
do_oper(GET): entered
There are 0 cookies in the cache
GET /Design_Time_Addresses/RusconiELineWS/Service1/ HTTP/1.1
Host: 192.168.15.41:8733
User-Agent: http-api/1.38
Content-Type: text/xml
SOAPAction: "GetValue"
Content-Length: 230


senddoc(): entered
<?xml version="1.0" encoding="utf-8"?>  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/"> <soapenv:Header/> <soapenv:Body> <tem:Leggi/> </soapenv:Body> </soapenv:Envelope>
recvresp(): entered
HTTP/1.1 200 OK
Content-Length: 3163
Content-Type: text/html; charset=UTF-8
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 23 Nov 2021 10:29:03 GMT


SetError() £13: HTTP/1.1 200 OK
recvresp(): end with 200
recvdoc parms: identity 3163
header_load_cookies() entered
recvdoc(): entered
SetError() £0:
recvdoc(): Receiving 3163 bytes.
<HTML lang="en"><HEAD><link rel="alternate" type="text/xml" href="http://localhost:8733/Design_Time_Addresses/RusconiELineWS/Service1/?disco"/><STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{display: block; font-size: 1em;}</STYLE><TITLE>Service1 Service</TITLE></HEAD><BODY><DIV id="content" role="main"><h1 class="heading1">Service1 Service</h1><BR/><P class="intro">You have created a service.<P class='intro'>To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:</P> <BR/><PRE>svcutil.exe <A HREF="http://localhost:8733/Design_Time_Addresses/RusconiELineWS/Service1/?wsdl">http://localhost:8733/Design_Time_Addresses/RusconiELineWS/Service1/?wsdl</A></PRE><P>You can also access the service description as a single file:<BR/><PRE><A HREF="http://localhost:8733/Design_Time_Addresses/RusconiELineWS/Service1/?singleWsdl">http://localhost:8733/Design_Time_Addresses/RusconiELineWS/Service1/?singleWsdl</A></PRE></P></P><P class="intro">This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:<BR/></P><h2 class='intro'>C#</h2><br /><PRE><font color="blue">class </font><font color="black">Test
</font>{
<font color="blue">    static void </font>Main()
    {
        <font color="black">Service1Client</font> client = <font color="blue">new </font><font color="black">Service1Client</font>();

<font color="darkgreen">        // Use the 'client' variable to call operations on the service.

</font><font color="darkgreen">        // Always close the client.
</font>        client.Close();
    }
}
</PRE><BR/><h2 class='intro'>Visual Basic</h2><br /><PRE><font color="blue">Class </font><font color="black">Test
</font><font color="blue">    Shared Sub </font>Main()
<font color="blue">        Dim </font>client As <font color="black">Service1Client</font> = <font color="blue">New </font><font color="black">Service1Client</font>()
<font color="darkgreen">        ' Use the 'client' variable to call operations on the service.

</font><font color="darkgreen">        ' Always close the client.
</font>        client.Close()
<font color="blue">    End Sub
</font><font color="blue">End Class</font></PRE></DIV></BODY></HTML>
http_close(): entered
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: Unespected response

Post by Scott Klement »

You are using a GET request, which doesn't make any sense.

Can you please provide the WSDL? It's hard to tell what you are doing wrong if we don't have the specifications for how it's supposed to work.
ANDREA.P
Posts: 3
Joined: Wed Nov 24, 2021 9:18 am

Re: Unespected response

Post by ANDREA.P »

Thank you Scott.
I tried even with POST.

Code: Select all

       ctl-opt DECEDIT('0,')                                                                     
               datedit(*dmy) datfmt(*iso)                                                        
               option(*nodebugio) bnddir('HTTPAPI');                                             
      //                                                                                         
       DCL-S url              VARCHAR(100);                                                      
       DCL-S soap             VARCHAR(1000);                                                     
       DCL-S response         VARCHAR(100000);                                                   
      /copy httpapi_h                                                                            
       http_debug(*On:'/tmp/mydebuglog.txt');                                                    
       //***************************************************************                         
       // LETTURA DELLA PRODUZIONE ISTANTANEA                                                    
       //***************************************************************                         
         http_setOption('SoapAction': '"GetValue"');                                             
         //                                                                                      
         url = 'http://192.168.15.41:8733/+                                                      
         Design_Time_Addresses/RusconiELineWS/Service1/';                                        
         soap = '<soapenv:Envelope +                                                             
             xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" +                         
             xmlns:tem="http://tempuri.org/"> +                                                  
             <soapenv:Header/> +                                                                 
             <soapenv:Body> +                                                                    
             <tem:Leggi/> +                                                                      
             </soapenv:Body> +                                                                   
             </soapenv:Envelope>';                                                               
         //                                                                                      
         response = http_string( 'POST' : url : SOAP : 'text/xml');                              
         *inlr = *on;                                                                            
         RETURN;     


This is the error i get:

Code: Select all

                      Ulteriori informazioni sui messaggi                       
                                                                                
 ID messaggio . . . . . :   RNQ0202       Gravità  . . . . . . . :   99         
 Tipo di messaggio  . . :   Interrogazione                                      
 Data invio . . . . . . :   29/11/21      Ora invio  . . . . . . :   18:49:47   
                                                                                
 Messaggio . . . :   Chiamata a HTTP_STRIN terminata con errore (C G D F).      
 Causa . . . . . :   La procedura RPG PMYRUS nel programma COM80OBJ/PMYRUS      
   all'istruzione 2698 ha richiamato un programma o una procedura HTTP_STRIN,   
   terminata con errore. Se il nome è *N, la chiamata era una chiamata          
   collegata tramite il puntatore della procedura.                              
 Correzione . . . : Per ulteriori informazioni sulla causa dell'errore          
   controllare la registrazione lavori e contattare il responsabile della       
   manutenzione dei programmi.                                                  
 Scelte possibili per la risposta al messaggio . . . . . . . . . . . . . . . :  
   D -- Per ottenere un dump formattato RPG.                                    
   S -- Ottenere un dump di sistema.                                            
   G -- Continuare l'elaborazione a *GETIN.                                     
                                                                       Segue...        


The WDSL file.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><wsdl:definitions name="Service1" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><wsdl:types><xs:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:import namespace="http://schemas.datacontract.org/2004/07/RusconiELineWS"/><xs:element name="DoWork"><xs:complexType><xs:sequence/></xs:complexType></xs:element><xs:element name="DoWorkResponse"><xs:complexType><xs:sequence/></xs:complexType></xs:element><xs:element name="Imposta"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="commessa" nillable="true" type="q1:InfoCommessaImposta" xmlns:q1="http://schemas.datacontract.org/2004/07/RusconiELineWS"/></xs:sequence></xs:complexType></xs:element><xs:element name="ImpostaResponse"><xs:complexType><xs:sequence/></xs:complexType></xs:element><xs:element name="Leggi"><xs:complexType><xs:sequence/></xs:complexType></xs:element><xs:element name="LeggiResponse"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="LeggiResult" nillable="true" type="q2:InfoCommessaRestituiti" xmlns:q2="http://schemas.datacontract.org/2004/07/RusconiELineWS"/></xs:sequence></xs:complexType></xs:element></xs:schema><xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/"><xs:element name="anyType" nillable="true" type="xs:anyType"/><xs:element name="anyURI" nillable="true" type="xs:anyURI"/><xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/><xs:element name="boolean" nillable="true" type="xs:boolean"/><xs:element name="byte" nillable="true" type="xs:byte"/><xs:element name="dateTime" nillable="true" type="xs:dateTime"/><xs:element name="decimal" nillable="true" type="xs:decimal"/><xs:element name="double" nillable="true" type="xs:double"/><xs:element name="float" nillable="true" type="xs:float"/><xs:element name="int" nillable="true" type="xs:int"/><xs:element name="long" nillable="true" type="xs:long"/><xs:element name="QName" nillable="true" type="xs:QName"/><xs:element name="short" nillable="true" type="xs:short"/><xs:element name="string" nillable="true" type="xs:string"/><xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/><xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/><xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/><xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/><xs:element name="char" nillable="true" type="tns:char"/><xs:simpleType name="char"><xs:restriction base="xs:int"/></xs:simpleType><xs:element name="duration" nillable="true" type="tns:duration"/><xs:simpleType name="duration"><xs:restriction base="xs:duration"><xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/><xs:minInclusive value="-P10675199DT2H48M5.4775808S"/><xs:maxInclusive value="P10675199DT2H48M5.4775807S"/></xs:restriction></xs:simpleType><xs:element name="guid" nillable="true" type="tns:guid"/><xs:simpleType name="guid"><xs:restriction base="xs:string"><xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/></xs:restriction></xs:simpleType><xs:attribute name="FactoryType" type="xs:QName"/><xs:attribute name="Id" type="xs:ID"/><xs:attribute name="Ref" type="xs:IDREF"/></xs:schema><xs:schema elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/RusconiELineWS" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/RusconiELineWS"><xs:complexType name="InfoCommessaImposta"><xs:sequence><xs:element minOccurs="0" name="CodiceArticolo" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="NumeroCommessa" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="QtaDaProdurre" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="Valori" nillable="true" type="tns:ArrayOfValoriImposta"/></xs:sequence></xs:complexType><xs:element name="InfoCommessaImposta" nillable="true" type="tns:InfoCommessaImposta"/><xs:complexType name="ArrayOfValoriImposta"><xs:sequence><xs:element minOccurs="0" maxOccurs="unbounded" name="ValoriImposta" nillable="true" type="tns:ValoriImposta"/></xs:sequence></xs:complexType><xs:element name="ArrayOfValoriImposta" nillable="true" type="tns:ArrayOfValoriImposta"/><xs:complexType name="ValoriImposta"><xs:sequence><xs:element minOccurs="0" name="Chiave" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="Valore" nillable="true" type="xs:string"/></xs:sequence></xs:complexType><xs:element name="ValoriImposta" nillable="true" type="tns:ValoriImposta"/><xs:complexType name="InfoCommessaRestituiti"><xs:sequence><xs:element minOccurs="0" name="Numero" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="QtaBusteProdotte" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="Valori" nillable="true" type="tns:ArrayOfValoriRicevi"/></xs:sequence></xs:complexType><xs:element name="InfoCommessaRestituiti" nillable="true" type="tns:InfoCommessaRestituiti"/><xs:complexType name="ArrayOfValoriRicevi"><xs:sequence><xs:element minOccurs="0" maxOccurs="unbounded" name="ValoriRicevi" nillable="true" type="tns:ValoriRicevi"/></xs:sequence></xs:complexType><xs:element name="ArrayOfValoriRicevi" nillable="true" type="tns:ArrayOfValoriRicevi"/><xs:complexType name="ValoriRicevi"><xs:sequence><xs:element minOccurs="0" name="Chiave" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="DataOra" nillable="true" type="xs:string"/><xs:element minOccurs="0" name="Valore" nillable="true" type="xs:string"/></xs:sequence></xs:complexType><xs:element name="ValoriRicevi" nillable="true" type="tns:ValoriRicevi"/></xs:schema></wsdl:types><wsdl:message name="IService1_DoWork_InputMessage"><wsdl:part name="parameters" element="tns:DoWork"/></wsdl:message><wsdl:message name="IService1_DoWork_OutputMessage"><wsdl:part name="parameters" element="tns:DoWorkResponse"/></wsdl:message><wsdl:message name="IService1_Imposta_InputMessage"><wsdl:part name="parameters" element="tns:Imposta"/></wsdl:message><wsdl:message name="IService1_Imposta_OutputMessage"><wsdl:part name="parameters" element="tns:ImpostaResponse"/></wsdl:message><wsdl:message name="IService1_Leggi_InputMessage"><wsdl:part name="parameters" element="tns:Leggi"/></wsdl:message><wsdl:message name="IService1_Leggi_OutputMessage"><wsdl:part name="parameters" element="tns:LeggiResponse"/></wsdl:message><wsdl:portType name="IService1"><wsdl:operation name="DoWork"><wsdl:input wsaw:Action="http://tempuri.org/IService1/DoWork" message="tns:IService1_DoWork_InputMessage"/><wsdl:output wsaw:Action="http://tempuri.org/IService1/DoWorkResponse" message="tns:IService1_DoWork_OutputMessage"/></wsdl:operation><wsdl:operation name="Imposta"><wsdl:input wsaw:Action="http://tempuri.org/IService1/Imposta" message="tns:IService1_Imposta_InputMessage"/><wsdl:output wsaw:Action="http://tempuri.org/IService1/ImpostaResponse" message="tns:IService1_Imposta_OutputMessage"/></wsdl:operation><wsdl:operation name="Leggi"><wsdl:input wsaw:Action="http://tempuri.org/IService1/Leggi" message="tns:IService1_Leggi_InputMessage"/><wsdl:output wsaw:Action="http://tempuri.org/IService1/LeggiResponse" message="tns:IService1_Leggi_OutputMessage"/></wsdl:operation></wsdl:portType><wsdl:binding name="BasicHttpBinding_IServiceEasyPermissionsWin" type="tns:IService1"><soap:binding transport="http://schemas.xmlsoap.org/soap/http"/><wsdl:operation name="DoWork"><soap:operation soapAction="http://tempuri.org/IService1/DoWork" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="Imposta"><soap:operation soapAction="http://tempuri.org/IService1/Imposta" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation><wsdl:operation name="Leggi"><soap:operation soapAction="http://tempuri.org/IService1/Leggi" style="document"/><wsdl:input><soap:body use="literal"/></wsdl:input><wsdl:output><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="Service1"><wsdl:port name="BasicHttpBinding_IServiceEasyPermissionsWin" binding="tns:BasicHttpBinding_IServiceEasyPermissionsWin"><soap:address location="http://localhost:8733/Design_Time_Addresses/RusconiELineWS/Service1/"/></wsdl:port></wsdl:service></wsdl:definitions>   
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: Unespected response

Post by Scott Klement »

The WSDL file shows 3 possible operations:
  • DoWork which has SoapAction="http://tempuri.org/IService1/DoWork"
  • Imposta, which has SoapAction="http://tempuri.org/IService1/Imposta"
  • Leggi, "http://tempuri.org/IService1/Leggi"
All of them are POST operations.
None of them use a SoapAction of "GetValue".

Your latest message shows that http_string() is crashing with an RNQ0202 error. You have not mentioned this previously at all. The message says "Check the job log for more information." What does it say in the job log?
ANDREA.P
Posts: 3
Joined: Wed Nov 24, 2021 9:18 am

Re: Unespected response

Post by ANDREA.P »

Thank you Scott for your help.
The problem is solved.
This is the right soap action:

Code: Select all

http_setOption('SoapAction':              
 '"http://tempuri.org/IService1/Leggi"'); 
Post Reply