PDA

View Full Version : how to display a string


alexsystems
05-06-2003, 09:02 AM
what is the syntax on displaying a returned string? smaple code provided...
when you click the button - the ruturned data is supposed to be string. how can i display it? thanks


<canvas debug="true">
<dataset name="myData"
src="http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl"
type="http"
autorequest="false"/>
<button>Get Currency
<method event="onclick">
var c1 = 'united states';
var c2 = 'philippines';
var ds = canvas.datasets.myData;
ds.setQueryString( {country1 : c1 } );
ds.setQueryString( {country2 : c2 } );
ds.doRequest();
</method>
</button>
</canvas>

antun
05-06-2003, 09:25 AM
If you just want to see what comes back, then serialize the datapath:


<canvas debug="true">
<dataset name="myData"
src="http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl"
type="http"
autorequest="false"/>

<view datapath="myData:/"
ondata="debug.write( this.datapath.serialize() )" />

<button>Get Currency
<method event="onclick">
var c1 = 'united states';
var c2 = 'philippines';
var ds = canvas.datasets.myData;
ds.setQueryString( {country1 : c1 } );
ds.setQueryString( {country2 : c2 } );
ds.doRequest();
</method>
</button>
</canvas>


Is that what you meant?

Otherwise if you're trying to list the data that comes back, you'd use a view with a datapath so that it would get replicated.

Or if you're trying to get to a specific point in the data, you'd set up a datapointer and home in on the data you want.

-Antun

alexsystems
05-06-2003, 09:34 AM
i want to list or display the returned results. i thought the datapath is only used if the returned results is xml. what is the syntax to display it as text. how about below...

<view name="content" datapath="airportdata:/">
<text>@content</text>
</view>

antun
05-06-2003, 09:50 AM
In this case, the returned result is XML. Your script gets the XML for this page:

http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl?country1=united+state s&country2=philippenes

... which is perfectly valid XML.

Here's an example of how you would list the name attributes of the two "message" tags:


<canvas debug="true">
<dataset name="myData"
src="http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl"
type="http"
autorequest="false"/>

<view datapath="myData:/definitions" y="50">
<simplelayout axis="y" spacing="3" />
<view datapath="message">
<text datapath="@name" />
</view>
</view>

<button>Get Currency
<method event="onclick">
var c1 = 'united states';
var c2 = 'philippines';
var ds = canvas.datasets.myData;
ds.setQueryString( {country1 : c1 } );
ds.setQueryString( {country2 : c2 } );
ds.doRequest();
</method>
</button>
</canvas>


The outer view gets its datapath set to the root node (definitions). Next, it's first child view gets a datapath set to "message", which means that one of those views will be created for every message tag at that level of the xml document. (2 here).

Finally there's a text element whose datapath is set to @name, meaning the attribute named "name" in the datapath of it's parent (i.e. <message>).

Text is special in that if you give it a datapath that returns a string (either @attributeName or text()), it will write out the string.

Does that help?

-Antun

alexsystems
05-06-2003, 10:08 AM
i'm still not getting the result i need. according to this service it should return a float. the only data displayed is getRateRequest and getRateReponse. also, why is it that i'm not seing the rest of the debug.

<body><definitions name="CurrencyExchangeService" targetNamespace="http://www.xmethods.net/sd/CurrencyExchangeService.wsdl"><message name="getRateRequest"><part name="country1" type="xsd:string"/><part name="country2" type="xsd:string"/></message><message name="getRateResponse"><part name="Result" type="xsd:float"/></message><portType name="CurrencyExchangePortType"><operation name="getRate"><input message="tns:getRateRequest"/><output message="tns:getRateResponse"/></operation></portType><bi...


Request Parameter Schema:
<element name="country1" type="string" />
<element name="country2" type="string" />

Response Parameter Schema:
<element name="return" type="float" />

antun
05-06-2003, 10:21 AM
Here is what the service is returning:


<?xml version="1.0"?>
<definitions name="CurrencyExchangeService"
targetNamespace="http://www.xmethods.net/sd/CurrencyExchangeService.wsdl"
xmlns:tns="http://www.xmethods.net/sd/CurrencyExchangeService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="getRateRequest">
<part name="country1" type="xsd:string"/>
<part name="country2" type="xsd:string"/>
</message>
<message name="getRateResponse">
<part name="Result" type="xsd:float"/>
</message>
<portType name="CurrencyExchangePortType">
<operation name="getRate">
<input message="tns:getRateRequest" />
<output message="tns:getRateResponse" />
</operation>
</portType>
<binding name="CurrencyExchangeBinding" type="tns:CurrencyExchangePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getRate">
<soap:operation soapAction=""/>
<input >
<soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output >
<soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="CurrencyExchangeService">
<documentation>Returns the exchange rate between the two currencies</documentation>
<port name="CurrencyExchangePort" binding="tns:CurrencyExchangeBinding">
<soap:address location="http://services.xmethods.net:80/soap"/>
</port>
</service>
</definitions>


This is what would get returned by goign to the following URL:

http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl?country1=united+state s&country2=philippines

... which is the URL that this part of your code will request:


var c1 = 'united states';
var c2 = 'philippines';
var ds = canvas.datasets.myData;
ds.setQueryString( {country1 : c1 } );
ds.setQueryString( {country2 : c2 } );


I don't see the float you're talking about anywhere in it. Can you tell me the URL you type into the browser to get the float you saw?

WRT the text length field, that's a problem with the Flash player truncating text field widths to the canvas width. This should be fixed in an upcoming release of the LPS (you'll be able to specify the max text width for any text field in the app irrespective of the canvas size).

-Antun

alexsystems
05-06-2003, 10:29 AM
the url is below - sample codes... it also looks like it uses a method called getRate

http://www.xmethods.net/ve2/ViewListing.po;jsessionid=2iuRwkck54Do-QEel6sbeOLy(QhxieSRM)?key=uuid:D784C184-99B2-DA25-ED45-3665D11A12E5

COLDFUSION EXAMPLE

<!--- Invoke web service --->
<CFINVOKE WEBSERVICE="http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl"
METHOD="getRate"
RETURNVARIABLE="aRate">
<CFINVOKEARGUMENT NAME="country1"
VALUE="#c1#"/>
<CFINVOKEARGUMENT NAME="country2"
VALUE="#c2#"/>
</CFINVOKE>

antun
05-06-2003, 10:45 AM
The URL you sent me doesn't return an XML document with a float (or I'm doing something very wrong). Instead it returns the reference page for the web service.

Can you send me the URL that you put in your browser so that you see the XML document and float in your browser?

-Antun

alexsystems
05-06-2003, 11:06 AM
i did not really see the result. the only thing i get is the xml format you provided a while ago. the url i provided were sample codes that used path that i'm using. just like the example i provided above with two parameters. for some reason the example they provided returned results.