HomeDigital EditionSys-Con RadioSearch Web Services Cd
B2B Beginning WS Business Process Management Case Studies Content Management Distributing Computing e-Business Electronic Data Interchange Enterprise Industry Insight Integration Interviews Java & Web Services .NET Portal Product Reviews Scalability & Performance Security SOAP Source Code UDDI Wireless WS Standards WS Tips & Techniques WSDL WS Editorials XML

Web Services Development with PowerBuilder 9 by Jinyou Zhu
WSJ Vol 03 Issue 1 - pg.43

	


Listing 1: Calling Web Service from PowerScript

long l_ret
real r_rate

SoapConnection conn 
demo_currencyexchangeport p_obj 	

//Create connection instance
conn =  create SoapConnection

//Set options for the connection
conn.SetOptions("SoapLog=~"c:\\soaplog.txt~"")

// Create proxy instance
l_ret = Conn.CreateInstance(p_obj, "demo_currencyexchangeport")
if l_ret <> 0 then
    MessageBox("Error", "Cannot create instance of proxy")
    return
end if

// Invoke Web Service
try
    r_rate = p_obj.GetRate("us","japan")
    MessageBox("Currency Exchange Rate","1 US$ = "+ string(r_rate) + " Japanese Yens")
catch ( SoapException e )
    MessageBox ("Error", "Cannot invoke Web Service~n" +e.getMessage())
end try

destroy conn

Listing 2: TLD File for currency exchange Web Service 

<?xml version="1.0" encoding="ISO-8859-1" ?> 
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.
//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> 

<taglib> 
    <tlibversion>1.0</tlibversion>
    <jspversion>1.1</jspversion>
    <shortname>CurrencyExchangeService</shortname>

    <tag> 
        <name>getRate</name>
        <tagclass>CurrencyExchangeService.getRate</tagclass> 
        <teiclass>CurrencyExchangeService.getRate_tei</teiclass> 
        <bodycontent>EMPTY</bodycontent> 
        <attribute>
            <name>country1</name> 
            <required>yes</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>country2</name> 
            <required>yes</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>
</taglib>

Listing 3: Calling Web Service from JSP application

<%@ taglib prefix="sg" uri="WEB-INF/tlds/CurrencyExchangeService.tld" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
    <META HTTP-EQUIV="PowerSiteData" NAME="SERVERLANGUAGE" CONTENT="Java">
    <TITLE>DemoPage</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <META content="PB9.0.0.5001" name="GENERATOR">
</HEAD>
<BODY bgColor="white" PSPARAMS="">
<P>1US$ =  </P>
<P><sg:getRate country1="us" country2="japan" /></P>
<P><%= CurrencyExchangeService_getRate_returnValue %></P>
<P>Japanese Yens  </P>
</BODY>
</HTML>