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

RE: SOAPAction error



Ok guy, I got this working following sending the SOAPAction, i had put in an IP address in the URI for the action rather than localhost.
For those interested and for reference, the code listed below is now fully working:
 
 *  This is an example of calling a SOAP Web service w/HTTPAPI. 
 *                                                              
H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')                      
                                                                
D SAPTEST4        PR                  ExtPgm('SAPTEST4')        
D   cname                       20A   const                     
D   cname2                      20A   const                     
D   cname3                      20A   const                     
D   cname4                      20A   const                     
D   ccity                       20A   const                     
D   cpost                        7A   const                     
D   ccntry                       2A   const                     
D   clang                        2A   const                     
D   ctel                        15A   const                     
D   cfax                        15A   const                     
D   cemail                      35A   const                     
D   ccurr                        3A   const                  
D   csalorg                      4A   const                  
D   cdistri                      2A   const                  
D   cdivi                        2A   const                  
D   crefcus                     10A   const                  
D SAPTEST4        PI                                         
D   cname                       20A   const                  
D   cname2                      20A   const                  
D   cname3                      20A   const                  
D   cname4                      20A   const                  
D   ccity                       20A   const                  
D   cpost                        7A   const                  
D   ccntry                       2A   const                  
D   clang                        2A   const                  
D   ctel                        15A   const                  
D   cfax                        15A   const                  
D   cemail                      35A   const                            
D   ccurr                        3A   const                            
D   csalorg                      4A   const                            
D   cdistri                      2A   const                            
D   cdivi                        2A   const                            
D   crefcus                     10A   const                            
                                                                       
 /copy httpapi_h                                                       
                                                                       
 **********************************************************************
 * DEFINE XML READ FUNCTIONS                                           
 * (for reading the headers and details for each element)              
 **********************************************************************
D StartElement    PR                                                   
D   UserData                      *   value                            
D   depth                       10I 0 value                            
D   name                      1024A   varying const                    
D   path                     24576A   varying const              
D   attrs                         *   dim(32767)                 
D                                     const options(*varsize)    
                                                                 
D EndElement      PR                                             
D   UserData                      *   value                      
D   depth                       10I 0 value                      
D   name                      1024A   varying const              
D   path                     24576A   varying const              
D   value                    32767A   varying const              
D   attrs                         *   dim(32767)                 
D                                     const options(*varsize)    
                                                                 
D SOAP            s          32767A   varying                    
D rc              s             10I 0                            
D custdetail      s          32767A                              
D fault           s          32767A                              
 
/free                                                            
 if ( %parms < 1 );                                              
    http_comp('Please pass all customer details');               
    return;                                                      
 endif;                                                          
                                                                 
 SOAP =                                                          
  '<?xml version="1.0" encoding="utf-8"?>'                       
 +'<soap:Envelope '                                              
 +'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; '       
 +'xmlns:xsd="http://www.w3.org/2001/XMLSchema"; '                
 +'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>'      
 +'<soap:Body>'                                                  
 +'<CreateNewCustomer xmlns="http://localhost/SAPWebService";>'   
 +'  <Cust_Name>'+ %trim(cname) +'</Cust_Name>'                  
 +'  <Cust_Name_2>'+ %trim(cname2) +'</Cust_Name_2>'             
 +'  <Cust_Name_3>'+ %trim(cname3) +'</Cust_Name_3>'             
 +'  <Cust_Name_4>'+ %trim(cname4) +'</Cust_Name_4>'           
 +'  <Cust_City>'+ %trim(ccity) +'</Cust_City>'                
 +'  <Cust_Postcode>'+ %trim(cpost) +'</Cust_Postcode>'        
 +'  <Cust_Country>'+ %trim(ccntry) +'</Cust_Country>'         
 +'  <Cust_Language>'+ %trim(clang) +'</Cust_Language>'        
 +'  <Cust_Telephone>'+ %trim(ctel) +'</Cust_Telephone>'       
 +'  <Cust_Faxnumber>'+ %trim(cfax) +'</Cust_Faxnumber>'       
 +'  <Cust_Email>'+ %trim(cemail) +'</Cust_Email>'             
 +'  <Cust_Currency>'+ %trim(ccurr) +'</Cust_Currency>'        
 +'  <Cust_Salesorg>'+ %trim(csalorg) +'</Cust_Salesorg>'      
 +'  <Cust_Distrib>'+ %trim(cdistri) +'</Cust_Distrib>'        
 +'  <Cust_Division>'+ %trim(cdivi) +'</Cust_Division>'        
 +'  <Cust_RefCust>'+ %trim(crefcus) +'</Cust_RefCust>'        
 +'</CreateNewCustomer>'                                       
 +'</soap:Body>'                                               
 +'</soap:Envelope>';                                          
 
 http_debug(*ON);                                                
                                                                 
 rc = http_url_post_xml(                                         
            'http://10.186.194.2/SAPWebService/Service1.asmx'    
                   : %addr(SOAP) + 2                             
                   : %len(SOAP)                                  
                   : %paddr(StartElement)                        
                   : %paddr(EndElement)                          
                   : *NULL                                       
                   : HTTP_TIMEOUT                                
                   : HTTP_USERAGENT                              
                   : 'text/xml'                                  
                   : 'http://localhost/SAPWebService/Create'     
 +'NewCustomer');                                                
                                                                 
 if (rc <> 1);                                                   
    if (%trim(fault)<>'');                                       
          http_comp(%trim(fault));                                     
     else;                                                             
          http_crash();                                                
     endif;                                                            
  else;                                                                
     http_comp('New customer created with ref: ' + %trim(custdetail)); 
  endif;                                                               
                                                                       
  *inlr = *on;                                                         
                                                                       
 /end-free                                                             
                                                                       
 **********************************************************************
 * PROCEDURE TO HANDLE WHICH XML NODE WE ARE READING                   
 **********************************************************************
P StartElement    B                                                    
D StartElement    PI                                                   
D   UserData                      *   value                       
D   depth                       10I 0 value                       
D   name                      1024A   varying const               
D   path                     24576A   varying const               
D   attrs                         *   dim(32767)                  
D                                     const options(*varsize)     
                                                                  
 /free                                                            
 /end-free                                                        
P                       E
 **********************************************************************
 * PROCEDURE TO READ XML NODE VALUES TO LOCAL DATA ARRAY               
 **********************************************************************
                                                                       
P EndElement      B                                                    
D EndElement      PI                                                   
D   UserData                      *   value                            
D   depth                       10I 0 value                            
D   name                      1024A   varying const                    
D   path                     24576A   varying const                    
D   value                    32767A   varying const                    
D   attrs                         *   dim(32767)                       
D                                     const options(*varsize)          
                                                                       
 /free                                                                 
  select;                                                              
      when name = 'string';                                            
         custdetail = value;                                       
      when name = 'faultstring';                                   
         fault = value;                                            
  endsl;                                                           
 /end-free                                                         
P                 E                                                
 
regards
 
Chris Renton
Business Systems Developer
Sigmakalon
Ext 4213
 

________________________________

From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx on behalf of Scott Klement
Sent: Tue 24/07/2007 10:35 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: SOAPAction error



Hi Chris,

> I can run this webservice fine via its test page but with the iSeries
> I get a "Unable to handle request without a valid action parameter.
> Please supply a valid soap action."

I'm sorry if I'm restating the obvious, but..   Have you tried supplying
the appropriate soapaction?

Here's the sample code you supplied:

 >     rc = http_url_post_xml(
 >                'http://10.186.194.2/SAPWebService/Service1.asmx'
 >                       : %addr(SOAP) + 2
 >                       : %len(SOAP)
 >                       : %paddr(StartElement)
 >                       : %paddr(EndElement)
 >                       : *NULL );

The SOAPAction parameter is the 10th parameter to this API.  You are
only passing 6 parameters, consequently, you're not passing the
SOAPAction at all.  Therefore no SoapAction is sent.  Therefore you'll
get a message that says "Hey Chris, you need to pass the soap action!"
(Or "Please supply a valid soap action.")

I have no way of knowing what this particular web service requires for a
soap action parameter.  But once you determine what it should be, here's
where you pass it:

      rc = http_url_post_xml(
                 'http://10.186.194.2/SAPWebService/Service1.asmx'
                        : %addr(SOAP) + 2
                        : %len(SOAP)
                        : %paddr(StartElement)
                        : %paddr(EndElement)
                        : *NULL
                        : HTTP_TIMEOUT
                        : HTTP_USERAGENT
                        : 'text/xml'
                        : 'put your soap action here' );

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------



Official Sponsors of the Johnstone's Paint Trophy - Bringing Colour to the Beautiful Game  
www.johnstonestrade.com/johnstonespainttrophy

**************************************
-----------------------------------------
SigmaKalon UK Limited, registered in England (number 00436135), with its registered office at Huddersfield Road, Birstall, Batley, West Yorkshire, WF17 9XA.


PRIVATE AND CONFIDENTIAL
This Email may contain information that is privileged,confidential or otherwise protected from disclosure.  It must not be used by, or its contents copied or disclosed to persons other than the addressee(s).  If you have received this Email in error please notify our systems administrator on +44 (0)1924 354827 and delete the Email.

WARNING
It is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. Please carry out such virus and other checks as you consider appropriate. No responsibility is accepted by SigmaKalon UK Limited in this regard.
The contents of this e-mail may not necessarily represent the views or policies of SigmaKalon UK Limited.
No contracts may be concluded on behalf of SigmaKalon UK Limited by means of email communication.
SigmaKalon UK Limited may monitor the content of e-mails, as appropriate, to ensure its policies and procedures are being upheld by its employees.  
----------------------------------------
**************************************

<<winmail.dat>>

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------