Expand my Community achievements bar.

Calling Web Service from Flex (to PeopleSoft)

Avatar

Level 1
I'm new to Flex and web services. I've created a web service
in PeopleSoft and successfully imported the WSDL into Flex so that
it has contacted the PS server and returned data (using
mx:WebService and mx:Operation code I found examples of). However,
I have been unable to pass a parameter to the service from Flex
using that code. I then discovered and followed the sample code in
the Flex-generated package, but no matter what I do I cannot
successfully supply the "myValue" in the sample shown below. Here
is Flex's own text in my GetInfo.as file built by Flex:



* MXML sample code:

* First you need to map the package where the files were
generated to a namespace, usually on the <mx:Application>
tag, like this: xmlns:ws="com.draper.*"

* Define the service and within its tags set the request
wrapper for the desired operation

* <ws:GetInfo id="myService">

* <ws:FindID_request_var><ws:FindID_request
Find__CompIntfc__DL_TREE_IB_CI=myValue/>

* </ws:FindID_request_var>

* </ws:GetInfo>

* Then call the operation for which you have set the request
wrapper value above, like this:

* <mx:Button id="myButton" label="Call operation"
click="myService.FindID_send()" />





My code is:

<ws:GetInfo id="userRequest">

<ws:findID_request_var><ws:FindID_request
Find__CompIntfc__DL_TREE_IB_CI="X"/>

</ws:findID_request_var>

</ws:GetInfo>



When I try to run it, Flex is unhappy with the value I am
assigning ("X" above) no matter what I put there. If I omit the
double quotes and try to assign a text input field value (which is
my goal here), it complains that it expects a double quote. If I
put almost anything else there, it complains either:

Initializer for 'Find__CompIntfc__DL_TREE_IB_CI'; values of
type com.draper.Find__CompIntfc__DL_TREE_IB_CITypeShape cannot be
represented as text.

or, if I try this line, where I attempt to pass a text input
field:



<ws:FindID_request
Find__CompIntfc__DL_TREE_IB_CI="{compID.text}"/>



then I get:

1067: Implicit coercion of a value of type String to an
unrelated type com.draper:Find__CompIntfc__DL_TREE_IB_CITypeShape



Can anyone help with this please?



Thanks



Jim
2 Replies

Avatar

Level 1
Hi Jim,



I just started using Flex this week so I haven't tried making
calls using the method that you are (by importing the WSDL through
Data >
Import Web Service (WSDL)...), but I have been successful in
making calls via another method.



<mx:WebService id="webServiceID" wsdl="
http://yourwebsite/somefolder/service.wsdl">

<mx:operation name="operationName"
result="ResultHandler(event)"fault=

"FaultHandler(event)">

<mx:request>

<!-- parameters -->

</mx:request>

</mx:operation>

</mx:WebService>



To make the call, you would use the send() method on your
operation ("operationName" in the example above). Let's just say
you want to send the request on a button click. The code would look
like:



<mx:Button label="Send Web Service Request"
click="webServiceID.operationName.send()"/>



Please note that "operationName.send()" will not work alone -
you need to use "webServiceID.operationName.send()"



Hope this helps.



Cheers,

Chris





Avatar

Level 1
Chris,



Thanks. That is what I *was* doing, that got me all data
returned. The parameter never gets passed in the XML. It acts as if
a blank was passed and returns everything (just as you would expect
in the PeopleSoft search page when you just click Find without
specifying a key). It is expecting a partial key and will return
all keys that match (find method).



PS expects the key DL_CS_COMPID, and in Flex I've seen
Find__CompIntfc__DL_TREE_IB_CI also. So I've tried:

<mx:request>

<!-- <DL_CS_COMPID> -->

<Find__CompIntfc__DL_TREE_IB_CI>

{compID.text}

</Find__CompIntfc__DL_TREE_IB_CI>

<!-- </DL_CS_COMPID> -->

</mx:request>



(You can see I currently have dl_cs_compid commented out).
Both behave identically - they are ignored in the XML that is sent
from Flex. Here is a sample of what was received in PS:



<?xml version="1.0"?>

<M540564.V1:Find__CompIntfc__DL_TREE_IB_CI
xmlns:M540564.V1="
http://xmlns.oracle.com/Enterprise/Tools/schemas/M540564.V1"
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"/>



I believe there should be a
<DL_CS_COMPID>value</DL_CS_COMPID> string in there.