Topic
  • 10 replies
  • Latest Post - ‏2010-04-04T07:29:57Z by JohnxLong
SystemAdmin
SystemAdmin
535 Posts

Pinned topic Consuming Web service from RPG

‏2009-05-08T11:17:45Z |

Hello everyone,
I need a little assistance in consuming Web services from an RPG. I'm just taking my first steps in it.
I need to understand exactly what tools should i have in my system i, so that I can "simply" consume a specific web service.
I do understand the concept of the web service and its wsdl. I even created an RPG that it's "trying" to call CurrencyExchange, from the webservices site, but nothing happens. It looks like, in my iSeries, something's missing. I do have my HTTP server started.
Since I couldn't, I tried reading and trying it, and one of the first steps was soapUI get a WSDL.
http://www.scribd.com/doc/4735932/RPG-Consuming-Web-Services-With-HTTPAPI-and-SoapUI
When trying to get a WSDL from the webservices site, the tool stucks on "loading wsdl" and does nothing, so I'm guessing something is missing, again!
Can anyone help me?
As anyone tried the tool WSDL2RPG?
Thanks a million
Rubi
Updated on 2010-04-04T07:29:57Z at 2010-04-04T07:29:57Z by JohnxLong
  • jack_callahan
    jack_callahan
    9 Posts

    Re: Consuming Web service from RPG

    ‏2009-05-08T17:32:42Z  
    Since your program is consuming the web service, it will be acting as a web browser, not a server.

    The web client functionality you need is provided by Scott's HTTPAPI tool in the article you reference.

    As far as the SoapUI, this string works for me:
    http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
    File>New Soap Project, name your project, cut and paste the full string (including the WSDL), and press OK.

    Make sure you can connect to www.webservicex.net

    HTH

    Good luck

    Jack
    Updated on 2009-05-08T17:32:42Z at 2009-05-08T17:32:42Z by jack_callahan
  • scott_klement
    scott_klement
    244 Posts

    Re: Consuming Web service from RPG

    ‏2009-05-08T18:45:57Z  
    Since your program is consuming the web service, it will be acting as a web browser, not a server.

    The web client functionality you need is provided by Scott's HTTPAPI tool in the article you reference.

    As far as the SoapUI, this string works for me:
    http://www.webservicex.net/CurrencyConvertor.asmx?WSDL
    File>New Soap Project, name your project, cut and paste the full string (including the WSDL), and press OK.

    Make sure you can connect to www.webservicex.net

    HTH

    Good luck

    Jack

    I've been having a lot of problems lately with www.webservicex.net -- I think there are too many people using it, and it can't keep up with the load. That could, possibly, be the reason you aren't getting any response from it. Do the other example programs included with HTTPAPI work? (Such as EXAMPLE1, EXAMPLE2, etc?) If they work, and it's only the webservicex.net ones that don't, I would say the problem is with webservicex.net
    If none of the examples work, I'd say the problem is likely with your network configuration. Perhaps your system isn't allowed to access the web according to your firewall rules? (But apparently your PC can't access webservicex.net either... which is why I wonder if it's not webservicex.net at fault? Or maybe it's both.)
    Anyway, there's a mailing list set up for FTPAPI & HTTPAPI, which might be a better place to have this discussion ( I don't check RPG Cafe very often):
    http://www.scottklement.com/mailman/listinfo/ftpapi

  • SystemAdmin
    SystemAdmin
    535 Posts

    Re: Consuming Web service from RPG

    ‏2009-05-12T08:23:56Z  

    I've been having a lot of problems lately with www.webservicex.net -- I think there are too many people using it, and it can't keep up with the load. That could, possibly, be the reason you aren't getting any response from it. Do the other example programs included with HTTPAPI work? (Such as EXAMPLE1, EXAMPLE2, etc?) If they work, and it's only the webservicex.net ones that don't, I would say the problem is with webservicex.net
    If none of the examples work, I'd say the problem is likely with your network configuration. Perhaps your system isn't allowed to access the web according to your firewall rules? (But apparently your PC can't access webservicex.net either... which is why I wonder if it's not webservicex.net at fault? Or maybe it's both.)
    Anyway, there's a mailing list set up for FTPAPI & HTTPAPI, which might be a better place to have this discussion ( I don't check RPG Cafe very often):
    http://www.scottklement.com/mailman/listinfo/ftpapi


    Hi Jack
    Thanks for your tips.
    I will take a look at that tool (HTTAPI), but isn't there other way for RPG to consume a Web service?
    I had no problem acessing www.webservicex.net will have to investigate this issue.
    Thanks again
    Rubi
  • SystemAdmin
    SystemAdmin
    535 Posts

    Re: Consuming Web service from RPG

    ‏2009-05-12T08:28:44Z  

    Hi Jack
    Thanks for your tips.
    I will take a look at that tool (HTTAPI), but isn't there other way for RPG to consume a Web service?
    I had no problem acessing www.webservicex.net will have to investigate this issue.
    Thanks again
    Rubi

    Hi Scott,
    Thanks for your answer.
    i will try to do as you said, and try different examples.
    Best regards
    Rubi
  • jack_callahan
    jack_callahan
    9 Posts

    Re: Consuming Web service from RPG

    ‏2009-05-12T18:11:22Z  

    Hi Scott,
    Thanks for your answer.
    i will try to do as you said, and try different examples.
    Best regards
    Rubi

    I will take a look at that tool (HTTAPI), but isn't there other way for RPG to consume a Web service?

    Rubi:
    There's an article in the April 2009 edition of the IBM Systems Magazine that describes setting up a WSDL client using Integrated Web Services for i, but parts of the code are generated in C, and the Web Services Client for ILE manual uses C++ in its examples. If you're comfortable with C (or using C functionality from RPG), that may be an avenue you want to pursue. Not something I've used yet.

    In any case, you'll definitely want to subscribe to the discussion group Scott mentioned.
    Web Services Client for I manual
    We're working on a PHP script to push System i generated reports as
    PDFs into a Sharepoint server via a WSDL client using the free Zend
    products (ZendCore for i, Zend Studio for Eclipse, i edition). Had some
    problems with client authentication, but we had the 'plumbing' working
    within a day- and I've never written a PHP script before. Most of the
    work was finding a PHP script that someone else had written to solve
    the problem, and tailoring the particulars to our situation. Such is
    the advantage of the open source world.
  • scott_klement
    scott_klement
    244 Posts

    Re: Consuming Web service from RPG

    ‏2009-05-12T18:42:05Z  

    I will take a look at that tool (HTTAPI), but isn't there other way for RPG to consume a Web service?

    Rubi:
    There's an article in the April 2009 edition of the IBM Systems Magazine that describes setting up a WSDL client using Integrated Web Services for i, but parts of the code are generated in C, and the Web Services Client for ILE manual uses C++ in its examples. If you're comfortable with C (or using C functionality from RPG), that may be an avenue you want to pursue. Not something I've used yet.

    In any case, you'll definitely want to subscribe to the discussion group Scott mentioned.
    Web Services Client for I manual
    We're working on a PHP script to push System i generated reports as
    PDFs into a Sharepoint server via a WSDL client using the free Zend
    products (ZendCore for i, Zend Studio for Eclipse, i edition). Had some
    problems with client authentication, but we had the 'plumbing' working
    within a day- and I've never written a PHP script before. Most of the
    work was finding a PHP script that someone else had written to solve
    the problem, and tailoring the particulars to our situation. Such is
    the advantage of the open source world.
    There are many ways to consume a web service. But you asked about HTTPAPI (that's what the article you referenced is about -- I should know, I wrote it!) You also asked about WSDL2RPG, which still uses HTTPAPI, but it attempts to generarte the RPG code needed to call HTTPAPI. (It is discussed on the same mailing list as HTTPAPI)

    HTTPAPI is my product, and unlike the alternatives, is an open source, free product. (Free as in freedom, as well as free as in beer.) I'll do what I can to assist you if you decide to go that route.

    http://www.scottklement.com/httpapi/

    Other alternatives include Brad Stone's GETURI (3rd party commercial product... good support. I don't think it helps with XML, though... just does the HTTP portion.)

    http://www.bvstools.com/geturi.html

    Bob Cozzi's iSockets (*I am not a fan!!* Also doesn't help with XML. Let's leave it at that.)

    http://www.isockets.net/

    IBM's Integrated Webservices tool (works very well, handles both the HTTP & XML, but is somewhat complicated to use, because currently requires strong knowledge of C and pointers to handle the parameters)

    http://www-03.ibm.com/systems/i/software/iws/
    Or you could use Java or PHP or another language's web service support, and call it from RPG...
    Updated on 2009-05-12T18:42:05Z at 2009-05-12T18:42:05Z by scott_klement
  • SystemAdmin
    SystemAdmin
    535 Posts

    Re: Consuming Web service from RPG

    ‏2009-06-04T13:11:45Z  
    There are many ways to consume a web service. But you asked about HTTPAPI (that's what the article you referenced is about -- I should know, I wrote it!) You also asked about WSDL2RPG, which still uses HTTPAPI, but it attempts to generarte the RPG code needed to call HTTPAPI. (It is discussed on the same mailing list as HTTPAPI)

    HTTPAPI is my product, and unlike the alternatives, is an open source, free product. (Free as in freedom, as well as free as in beer.) I'll do what I can to assist you if you decide to go that route.

    http://www.scottklement.com/httpapi/

    Other alternatives include Brad Stone's GETURI (3rd party commercial product... good support. I don't think it helps with XML, though... just does the HTTP portion.)

    http://www.bvstools.com/geturi.html

    Bob Cozzi's iSockets (*I am not a fan!!* Also doesn't help with XML. Let's leave it at that.)

    http://www.isockets.net/

    IBM's Integrated Webservices tool (works very well, handles both the HTTP & XML, but is somewhat complicated to use, because currently requires strong knowledge of C and pointers to handle the parameters)

    http://www-03.ibm.com/systems/i/software/iws/
    Or you could use Java or PHP or another language's web service support, and call it from RPG...

    Another commercial option is RPG XML Suite: www.rpg-xml.com
    there is a free trial download (that can be repeatedly extended)
    and various helpful articles by Aaron Bartell.
  • JohnxLong
    JohnxLong
    59 Posts

    Re: Consuming Web service from RPG

    ‏2009-06-15T20:50:11Z  

    Another commercial option is RPG XML Suite: www.rpg-xml.com
    there is a free trial download (that can be repeatedly extended)
    and various helpful articles by Aaron Bartell.

    Hi,
    I've recently been using the wsdl2ws tool on the iSeries, it generates all the C code for you from the WSDL file.
    My previous experience of C was limited, but with the use of a little common sense, debug and google I managed to get them working and can now code a new service up quite quickly.
    The three big issues I had were matching the C and RPG datatypes, understanding pointers and indirection and finally arrays,
    I've created a /copy member with the datatype definitions in, so that makes things easier,
    If you google C and this will explain the basics about pointers and indirection, its not hard once the penny drops
    Debugging the C code makes things much clearer, if you have a variable such as Value0 (you will see this quite a lot in the generated code) if you do an eval or attr you will generally see its a pointer where its pointing, if you do eval *Value0 or attr *Value0 you get the value the pointer points to, a single character if its a string or its value if its a numeric. It gets interesting when its a pointer to an xsdc__String_array, do an attr on this will show you how to code the array on the iseries, (its basically a datastructure with 3 elements, a pointer to an array of pointers to the data, an array size and the type of array, XSDC_STRING etc.
    Another tip is to ensure you have ENUM(*INT) on your compile instructions for the C code, wihout this you will get some strange results.
    If you need any help please feel free to drop me a line.
  • SystemAdmin
    SystemAdmin
    535 Posts

    Re: Consuming Web service from RPG

    ‏2009-08-24T21:06:14Z  
    • JohnxLong
    • ‏2009-06-15T20:50:11Z

    Hi,
    I've recently been using the wsdl2ws tool on the iSeries, it generates all the C code for you from the WSDL file.
    My previous experience of C was limited, but with the use of a little common sense, debug and google I managed to get them working and can now code a new service up quite quickly.
    The three big issues I had were matching the C and RPG datatypes, understanding pointers and indirection and finally arrays,
    I've created a /copy member with the datatype definitions in, so that makes things easier,
    If you google C and this will explain the basics about pointers and indirection, its not hard once the penny drops
    Debugging the C code makes things much clearer, if you have a variable such as Value0 (you will see this quite a lot in the generated code) if you do an eval or attr you will generally see its a pointer where its pointing, if you do eval *Value0 or attr *Value0 you get the value the pointer points to, a single character if its a string or its value if its a numeric. It gets interesting when its a pointer to an xsdc__String_array, do an attr on this will show you how to code the array on the iseries, (its basically a datastructure with 3 elements, a pointer to an array of pointers to the data, an array size and the type of array, XSDC_STRING etc.
    Another tip is to ensure you have ENUM(*INT) on your compile instructions for the C code, wihout this you will get some strange results.
    If you need any help please feel free to drop me a line.

    Hi - I am having serious troubles in making the correct XML file generated for using the web service in our company. I am exactly looking for the same information to use the complex structure that contaned AXISC_XSDTYPE like you explained. It will be a GREAT help if you can answer me. My C client stubs needs to generate the following XML:
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://www.eps.in.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <q0:paymentRequest>
    <q0:balanceInquiry>
    <security>
    <username>test</username>
    <password>test</password>
    </security>
    <sourceId>W0045</sourceId>
    <q0:giftCards>
    <q0:giftCard>
    <cardNumber>6035718888881000609</cardNumber>
    <transactionAmount>232</transactionAmount>
    <externalReferenceId>2323</externalReferenceId>
    </q0:giftCard>
    <q0:giftCard>
    <cardNumber>6035718888881000619</cardNumber>
    <transactionAmount>132</transactionAmount>
    <externalReferenceId>2323</externalReferenceId>
    </q0:giftCard>
    </q0:giftCards>
    </q0:balanceInquiry>
    </q0:paymentRequest>
    </soapenv:Body>
    </soapenv:Envelope>
    <hr />
    What I am able to do is I am able to generate the following XML:
    <?xml version='1.0' encoding='utf-8' ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Body>
    <ns1:payment xmlns:ns1="http://www.eps.in.com">
    <ns1:balanceInquiry>
    <security>
    <username>test </username>
    <password>test </password>
    </security>
    <sourceId>W0045</sourceId>
    <giftCards></giftCards>
    </ns1:balanceInquiry>
    <ns1:authorization xsi:nil="true"></ns1:authorization>
    </ns1:payment>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <hr />
    What I am having trouble is to generate the tag <giftCard> under <giftCards>. What ever changes I make I am only able to see <GiftCards> being generated and closed and not the sub tags. I am attaching my zip file with all the C programs in it and also the RPGLE that calls the web service method. I know you may not get a chance to look at all of these but just in case.
    1. To summarize I am not able to generate the second level tag <giftCard> under <giftCards>. I am not sure if it is an issue with the C program either. I think I will know that only if I can debug C program also.
    2. Secondly I will have to eliminate sending the <authorization> tag from being sent as the web serviceexpects only one of <balanceInquiry> or <authorization>.
    3. Let me know what you think. Also it will be helpful if you can let me know the logic you used for the complex two level data XML tag structure.
    Sorry for the big mail.
    regards
    Kalyan
    Attachments:
    EGCTEST_WS.RPGLE
    EGC Service.zip
  • JohnxLong
    JohnxLong
    59 Posts

    Re: Consuming Web service from RPG

    ‏2010-04-04T07:29:57Z  

    Hi - I am having serious troubles in making the correct XML file generated for using the web service in our company. I am exactly looking for the same information to use the complex structure that contaned AXISC_XSDTYPE like you explained. It will be a GREAT help if you can answer me. My C client stubs needs to generate the following XML:
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://www.eps.in.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
    <q0:paymentRequest>
    <q0:balanceInquiry>
    <security>
    <username>test</username>
    <password>test</password>
    </security>
    <sourceId>W0045</sourceId>
    <q0:giftCards>
    <q0:giftCard>
    <cardNumber>6035718888881000609</cardNumber>
    <transactionAmount>232</transactionAmount>
    <externalReferenceId>2323</externalReferenceId>
    </q0:giftCard>
    <q0:giftCard>
    <cardNumber>6035718888881000619</cardNumber>
    <transactionAmount>132</transactionAmount>
    <externalReferenceId>2323</externalReferenceId>
    </q0:giftCard>
    </q0:giftCards>
    </q0:balanceInquiry>
    </q0:paymentRequest>
    </soapenv:Body>
    </soapenv:Envelope>
    <hr />
    What I am able to do is I am able to generate the following XML:
    <?xml version='1.0' encoding='utf-8' ?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Body>
    <ns1:payment xmlns:ns1="http://www.eps.in.com">
    <ns1:balanceInquiry>
    <security>
    <username>test </username>
    <password>test </password>
    </security>
    <sourceId>W0045</sourceId>
    <giftCards></giftCards>
    </ns1:balanceInquiry>
    <ns1:authorization xsi:nil="true"></ns1:authorization>
    </ns1:payment>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    <hr />
    What I am having trouble is to generate the tag <giftCard> under <giftCards>. What ever changes I make I am only able to see <GiftCards> being generated and closed and not the sub tags. I am attaching my zip file with all the C programs in it and also the RPGLE that calls the web service method. I know you may not get a chance to look at all of these but just in case.
    1. To summarize I am not able to generate the second level tag <giftCard> under <giftCards>. I am not sure if it is an issue with the C program either. I think I will know that only if I can debug C program also.
    2. Secondly I will have to eliminate sending the <authorization> tag from being sent as the web serviceexpects only one of <balanceInquiry> or <authorization>.
    3. Let me know what you think. Also it will be helpful if you can let me know the logic you used for the complex two level data XML tag structure.
    Sorry for the big mail.
    regards
    Kalyan
    Attachments:
    EGCTEST_WS.RPGLE
    EGC Service.zip

    Hi
    Sorry for the delay replying , I dont appear to have had a notification of your post.
    Did you manage to resolve the problem?