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

RE: Calling a SOAP Web service w/HTTPAPI



Excellent!

There was just a question within the last couple of weeks if passing parameters on the url was "legal" on a post. The answer was yes and looks like this:

The post started here: http://www.scottklement.com/archives/ftpapi/201004/msg00034.html

Scott's answer and Thomas' question right before it are here:

-Scott wrote: Yes, that's completely legitimate and legal.
-
-On 4/28/2010 3:06 PM, Thomas Raddatz wrote:
- What I mean is: Does the HTTP protocol allow to add parameters to a URL
- when calling http_url_post_stmf() likes this:
-
-      url = 'http://localhost:8080/testService/UploadData?counter=34&size=1234
-
-      rc = http_url_post_stmf(url: ...);
-
- Thomas.

As you can see, the parameters are added to the URL the same as you would in the browser. Beware that special characters may need encoding to make it work. Thomas appears to have found his answer by using the relatively new WEBFORM procedures.

Mike 



> -----Original Message-----
> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-
> bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Tom Thomson
> Sent: Monday, May 10, 2010 12:43 PM
> To: 'HTTPAPI and FTPAPI Projects'
> Subject: RE: Calling a SOAP Web service w/HTTPAPI
> 
> Mike, thanks for taking the time to provide the detailed information
> below.
> Very helpful.  Yes, I knew nothing about SoapUI but I've since worked
> through the examples and found it very useful.  However, In the past, I
> have
> successfully connected to a number of web services via iSeries RPG and
> using
> Scott's articles as a reference.
> 
> >>one thing I've wondered about and maybe you can help answer this
> question...how come people ask for help about how to write a particular
> program but don't produce the necessary documentation to all that to be
> written?
> 
> In my case, all I really wanted to know was how (if) the RPG differs
> when
> calling a web service when there is a parameter specified in the URL of
> the
> web service.  I had tried to connect to the service using my usual ways
> and
> it wasn't working.  I provided a fictitious url in my question to this
> site
> since we paid a fair amount of money to have access to these web
> services
> and I didn't think it wise to put the web service names on the public
> internet.  I had hoped to receive a snip of code showing what changes
> might
> be needed because of a parameter in the URL.  I didn't expect someone
> to try
> to connect to the fictitious service.  After Scott couldn't connect to
> the
> "real" url, my problem is likely with the web service documentation
> I've
> received.  I've since asked for an updated version plus the location of
> the
> wsdl.
> 
> Once again, thanks for the information and your patience.
> 
> -Tom
> 
> 
> 
> -----Original Message-----
> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mike Krebs
> Sent: Monday, May 10, 2010 10:23 AM
> To: HTTPAPI and FTPAPI Projects
> Subject: RE: Calling a SOAP Web service w/HTTPAPI
> 
> Tom,
> 
> I hope you haven't given up...web services running on the IBM i are
> pretty
> cool!
> 
> It would appear your knowledge base is relatively low and you are
> looking
> for the quick way through. Unfortunately, unless your web service fits
> one
> of the examples exactly, you will have to learn about xml and HTTPAPI.
> 
> Fortunately, this is pretty easy. Scott's article will get you up to
> speed
> fairly quickly.
> 
> In addition, there are a ton of resources that talk about xml on the
> web. In
> 10 minutes you can breeze through
> http://www.w3schools.com/xml/default.asp
> and get a grasp on xml.
> 
> You are using a web service from a provider. They most likely have a
> "public" definition of the service available inside a WSDL document.
> This is
> the document SOAPUI is looking for. The learning curve on SOAPUI is
> less
> than 20 minutes to find the "well formed xml" (you don't need all the
> functions in SOAPUI).
> 
> One thing I've wondered about and maybe you can help answer this
> question...how come people ask for help about how to write a particular
> program but don't produce the necessary documentation to allow that to
> be
> written? Or maybe you were asking for instructions on how to use
> EXAMPLE18
> and not particular code?
> 
> The "what is this code doing" part of HTTPAPI takes some getting used
> to. It
> isn't hard to understand once you figure it out, but getting there can
> be
> challenging.
> 
> EXAMPLE18 is the currency converter example? The soap message obviously
> needs changes. The "xmlns:tns" is specific to the web service. All the
> elements with "tns" are specific to the service. This is where SOAPUI
> really
> helps. It will build the XML for you with correct elements.
> 
> The http_url_post_xml will post the SOAP to the URL listed. So, change
> the
> first parameter to point to your web service. Leave the next two
> parameters
> (SOAP and SOAP length). The next parameter is passed as a *NULL. You
> can
> probably do the same. The next parameter refers to the Incoming
> procedure
> that is in EXAMPLE18. Once HTTPAPI receives the XML, it will read
> through
> the XML and "call Incoming" for each element it encounters
> (specifically it
> will call it when it sees the /element). When Incoming sees the element
> called "ConversionRateResult", it converts what it finds in "value" to
> rate
> using the C (Unix) function atof. The parameters to Incoming are set
> and
> mostly do not need to be changed. For the most part, you can just add
> additional checks to incoming to pull out the values you need. There is
> a
> technique to this however. Notice "rate" is declared in the main
> program and
> its address is passed to the procedure. Also note that rate is declared
> on
> the PI as 8F (Scott's GE!
>  OIP example shows a string being passed). From the various examples of
> parsing the XML, you will see that variously passed as strings and
> numbers.
> You will have to decide what fits your service or if you have to
> retrieve
> multiple values. If you have to return multiple, you will build a data
> structure and pass that instead of a discrete value.
> 
> Just so you know...Thomas Raddatz has an utility to take a WSDL and
> generate
> a stub module or program for you. Again, a little learning curve but
> assuming you have access to WSDL, you can generate a complete
> module/program
> in short order. It can be downloaded here:
> http://www.tools400.de/English/Freeware/WSDL2RPG/wsdl2rpg.html Look in
> the
> FAQ folder for quick start instructions under "How to create a Test
> Program".
> 
> Good luck. Ask questions...most are answered by Scott or someone else
> on the
> list.
> Mike
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------