SOAP interface and Flex

View: New views
4 Messages — Rating Filter:   Alert me  

Parent Message unknown SOAP interface and Flex

by Dominik Piekarczyk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all.

This is my first message to the list.

First I'll introduce my idea:

A few days ago I've found eXist to be just ideal combination with Flex and it's web services interface. Flex has great tools for working with XML data and (in small applications) communication with an XML DB via web services could allow me avoiding server side software - it's pretty much, I don't have to use yet another language like Java, PHP, and so on.

BUT (the problem) :

Well, I cannot get proper response from xquery operation. I really really tried to manage it in many ways.

SOME FACTS:

  * xquery is the first web services' operation on my way that does not work. Some other do, like getVersion (here's the whole flex's web service definition):

    <mx:WebService
        wsdl="http://localhost:8080/exist/services/Version?wsdl"
        id="eXistVersionWS"
        result="queryWSResultHandler(event)"
        fault="queryWSFaultHandler(event)"
        useProxy="false">
        <mx:operation name="getVersion" />       
    </mx:WebService>

  * Another working operations:
        <mx:operation name="connect" result="connectQueryWSResultHandler(event)">       
            <mx:request xmlns="">
                <userId>admin</userId>
                <password>admin</password> (here I've changed password from default null)
            </mx:request>
        </mx:operation>

        <mx:operation name="disconnect">
            <mx:request xmlns="">
                <sessionId>{this.sessionId}</sessionId>
            </mx:request>
        </mx:operation>

        <mx:operation name="getResourceData">
            <mx:request xmlns="">
                <sessionId>{this.sessionId}</sessionId>       
                <path>{inputReourcePath.text}</path>
                <indent>true</indent>
                <xinclude>false</xinclude>
                <processXSLPI>false</processXSLPI>
            </mx:request>
        </mx:operation>

  * And this is the problematic operation:

        <mx:operation name="xquery" result="xqueryQueryWSResultHandler(event)">
            <mx:request xmlns="">
                <sessionId>{this.sessionId}</sessionId>
                <xquery>{encodedInput.text}</xquery>
            </mx:request>
        </mx:operation>

    I've checked the request several times, it's encoded properly (I've decoded it to be sure), sessionId works fine with getResourceData operation, so it's fine. I always get the message:

    [RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:8080/exist/services/Query"]. URL: http://localhost:8080/exist/services/Query"]

 
THE QUESTION(s):

  * Is it a problem with a query I'm sending? It's true that these are my first steps with xquery language, but I've tried sooo many examples from eXist resources and xquery sandbox that it's unlikely I couldn't just have one lucky shot :)
  * Could you give me some examples of <xquery> parameter that have to work (with existing default examples).
  * Do you see any other mistakes I could make?
  * Has anybody any experiences with combining Flex with such XML DBs? It seems to be so natural that it's just strange to me that I don't see any working examples.



Help me, please, I'm stuck. But the idea is too elegant I would like to give up.

Greetings

--
Dominik Piekarczyk
www.araneo.pl

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: SOAP interface and Flex

by Adam Retter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have you tried this with a really simple XQuery? e.g.


xquery version "1.0";

<dateTime>{current-dateTime()}</dateTime>


I would also recommend that you try this outside of Adobe Flex, do you
have something like Web Service Studio or oXygen (it has a Web Service
test tool). Try connecting to the service and sending your simple
query request from there, the nice thing about this is then that you
can see the SOAP Request and Response.

Also, you may find the REST interface easier than the SOAP interface.
With the REST interface you can GET for simple queries with a
querystring parameter _query or for more complex queries you can POST
an XQuery.

There is also a SOAPServer in eXist which is different to the default
SOAP Webservices you are using, you can find details in
EXIST_HOME/tools/SOAPServer - this will enable you to write and store
xqueries in the database and expose them as SOAP Webservices.

Thanks Adam

2008/7/1 Dominik Piekarczyk <dominik@...>:

> Hi all.
>
> This is my first message to the list.
>
> First I'll introduce my idea:
>
> A few days ago I've found eXist to be just ideal combination with Flex and
> it's web services interface. Flex has great tools for working with XML data
> and (in small applications) communication with an XML DB via web services
> could allow me avoiding server side software - it's pretty much, I don't
> have to use yet another language like Java, PHP, and so on.
>
> BUT (the problem) :
>
> Well, I cannot get proper response from xquery operation. I really really
> tried to manage it in many ways.
>
> SOME FACTS:
>
>   * xquery is the first web services' operation on my way that does not
> work. Some other do, like getVersion (here's the whole flex's web service
> definition):
>
>     <mx:WebService
>         wsdl="http://localhost:8080/exist/services/Version?wsdl"
>         id="eXistVersionWS"
>         result="queryWSResultHandler(event)"
>         fault="queryWSFaultHandler(event)"
>         useProxy="false">
>         <mx:operation name="getVersion" />
>     </mx:WebService>
>
>   * Another working operations:
>         <mx:operation name="connect"
> result="connectQueryWSResultHandler(event)">
>             <mx:request xmlns="">
>                 <userId>admin</userId>
>                 <password>admin</password> (here I've changed password from
> default null)
>             </mx:request>
>         </mx:operation>
>
>         <mx:operation name="disconnect">
>             <mx:request xmlns="">
>                 <sessionId>{this.sessionId}</sessionId>
>             </mx:request>
>         </mx:operation>
>
>         <mx:operation name="getResourceData">
>             <mx:request xmlns="">
>                 <sessionId>{this.sessionId}</sessionId>
>                 <path>{inputReourcePath.text}</path>
>                 <indent>true</indent>
>                 <xinclude>false</xinclude>
>                 <processXSLPI>false</processXSLPI>
>             </mx:request>
>         </mx:operation>
>
>   * And this is the problematic operation:
>
>         <mx:operation name="xquery"
> result="xqueryQueryWSResultHandler(event)">
>             <mx:request xmlns="">
>                 <sessionId>{this.sessionId}</sessionId>
>                 <xquery>{encodedInput.text}</xquery>
>             </mx:request>
>         </mx:operation>
>
>     I've checked the request several times, it's encoded properly (I've
> decoded it to be sure), sessionId works fine with getResourceData operation,
> so it's fine. I always get the message:
>
>     [RPC Fault faultString="HTTP request error"
> faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent
> type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error
> #2032: Stream Error. URL: http://localhost:8080/exist/services/Query"]. URL:
> http://localhost:8080/exist/services/Query"]
>
>
> THE QUESTION(s):
>
>   * Is it a problem with a query I'm sending? It's true that these are my
> first steps with xquery language, but I've tried sooo many examples from
> eXist resources and xquery sandbox that it's unlikely I couldn't just have
> one lucky shot :)
>   * Could you give me some examples of <xquery> parameter that have to work
> (with existing default examples).
>   * Do you see any other mistakes I could make?
>   * Has anybody any experiences with combining Flex with such XML DBs? It
> seems to be so natural that it's just strange to me that I don't see any
> working examples.
>
>
>
> Help me, please, I'm stuck. But the idea is too elegant I would like to give
> up.
>
> Greetings
>
> --
> Dominik Piekarczyk
> www.araneo.pl
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Exist-open mailing list
> Exist-open@...
> https://lists.sourceforge.net/lists/listinfo/exist-open
>
>



--
Adam Retter

eXist Developer
{ England }
adam@...
irc://irc.freenode.net/existdb

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: SOAP interface and Flex

by Dominik Piekarczyk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for your answer, Adam. My reply's below:
 
Have you tried this with a really simple XQuery? e.g.

xquery version "1.0";

<dateTime>{current-dateTime()}</dateTime>

This is a smart idea, no data is included so I don't have to worry about data paths. But the result is the same, unfortunately. I've tried that date function and even just to push <a>b</a> to the client.


I would also recommend that you try this outside of Adobe Flex, do you
have something like Web Service Studio or oXygen (it has a Web Service
test tool). Try connecting to the service and sending your simple
query request from there, the nice thing about this is then that you
can see the SOAP Request and Response.

So I tried. I used SoapUI tool and I've sent some requests. The result is the more less the same: I can connect, get resource, but I still don't have satisfying response while sending xquery.

This is an example of request and response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:exist">
   <soapenv:Header/>
   <soapenv:Body>
      <urn:xquery>
         <urn:sessionId>4630104</urn:sessionId>
<urn:xquery>eHF1ZXJ5IHZlcnNpb24gIjEuMCI7DQ08ZGF0ZVRpbWU+e2N1cnJlbnQtZGF0ZVRpbWUoKX08L2RhdGVUaW1lPg==</urn:xquery>
      </urn:xquery>
   </soapenv:Body>
</soapenv:Envelope>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <xqueryResponse xmlns="urn:exist">
         <xqueryReturn>
            <collections/>
            <hits>1</hits>
            <queryTime>0</queryTime>
         </xqueryReturn>
      </xqueryResponse>
   </soapenv:Body>
</soapenv:Envelope>

Is this what I was supposed to get as an answer? I expected rather current datetime, like in xquery sandbox. I've tried to broke the base64 data string and the server response with an exception. So it's good.

Also, you may find the REST interface easier than the SOAP interface.
With the REST interface you can GET for simple queries with a
querystring parameter _query or for more complex queries you can POST
an XQuery.
 
I will probably go to the REST interface. I preferred SOAP, it's much more elegant and handy in Flex.

There is also a SOAPServer in eXist which is different to the default
SOAP Webservices you are using, you can find details in
EXIST_HOME/tools/SOAPServer - this will enable you to write and store
xqueries in the database and expose them as SOAP Webservices.

I don't see it in my folder, but even if - I will rather use REST interface which is documented and I can count for some help from other developers.

Thanks Adam

Thanks Adam :)


Dominik

 
> Hi all.
>
> This is my first message to the list.
>
> First I'll introduce my idea:
>
> A few days ago I've found eXist to be just ideal combination with Flex and
> it's web services interface. Flex has great tools for working with XML data
> and (in small applications) communication with an XML DB via web services
> could allow me avoiding server side software - it's pretty much, I don't
> have to use yet another language like Java, PHP, and so on.
>
> BUT (the problem) :
>
> Well, I cannot get proper response from xquery operation. I really really
> tried to manage it in many ways.
>
> SOME FACTS:
>
>   * xquery is the first web services' operation on my way that does not
> work. Some other do, like getVersion (here's the whole flex's web service
> definition):
>
>     <mx:WebService
>         wsdl="http://localhost:8080/exist/services/Version?wsdl"
>         id="eXistVersionWS"
>         result="queryWSResultHandler(event)"
>         fault="queryWSFaultHandler(event)"
>         useProxy="false">
>         <mx:operation name="getVersion" />
>     </mx:WebService>
>
>   * Another working operations:
>         <mx:operation name="connect"
> result="connectQueryWSResultHandler(event)">
>             <mx:request xmlns="">
>                 <userId>admin</userId>
>                 <password>admin</password> (here I've changed password from
> default null)
>             </mx:request>
>         </mx:operation>
>
>         <mx:operation name="disconnect">
>             <mx:request xmlns="">
>                 <sessionId>{this.sessionId}</sessionId>
>             </mx:request>
>         </mx:operation>
>
>         <mx:operation name="getResourceData">
>             <mx:request xmlns="">
>                 <sessionId>{this.sessionId}</sessionId>
>                 <path>{inputReourcePath.text}</path>
>                 <indent>true</indent>
>                 <xinclude>false</xinclude>
>                 <processXSLPI>false</processXSLPI>
>             </mx:request>
>         </mx:operation>
>
>   * And this is the problematic operation:
>
>         <mx:operation name="xquery"
> result="xqueryQueryWSResultHandler(event)">
>             <mx:request xmlns="">
>                 <sessionId>{this.sessionId}</sessionId>
>                 <xquery>{encodedInput.text}</xquery>
>             </mx:request>
>         </mx:operation>
>
>     I've checked the request several times, it's encoded properly (I've
> decoded it to be sure), sessionId works fine with getResourceData operation,
> so it's fine. I always get the message:
>
>     [RPC Fault faultString="HTTP request error"
> faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent
> type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error
> #2032: Stream Error. URL: http://localhost:8080/exist/services/Query"]. URL:
> http://localhost:8080/exist/services/Query"]
>
>
> THE QUESTION(s):
>
>   * Is it a problem with a query I'm sending? It's true that these are my
> first steps with xquery language, but I've tried sooo many examples from
> eXist resources and xquery sandbox that it's unlikely I couldn't just have
> one lucky shot :)
>   * Could you give me some examples of <xquery> parameter that have to work
> (with existing default examples).
>   * Do you see any other mistakes I could make?
>   * Has anybody any experiences with combining Flex with such XML DBs? It
> seems to be so natural that it's just strange to me that I don't see any
> working examples.
>
>
>
> Help me, please, I'm stuck. But the idea is too elegant I would like to give
> up.
>
> Greetings
>
> --
> Dominik Piekarczyk
> www.araneo.pl
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Exist-open mailing list
> Exist-open@...
> https://lists.sourceforge.net/lists/listinfo/exist-open
>
>



--
Adam Retter

eXist Developer
{ England }
adam@...
irc://irc.freenode.net/existdb



--
--
Dominik Piekarczyk
www.araneo.pl
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Parent Message unknown Re: SOAP interface and Flex

by Dominik Piekarczyk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Roger for your response, I will answer to eXist list as well, maybe someone else would participate in the discussion or find the its content useful for himself.

I've tried REST API, Roger's suggestion with using CDATA is fine, but I've faced another problem: in Flex I can't send POST data in scalar format, and I need "key - value" format. Perl example in REST API documentation shows pushing xquery without a key. 

Have You any idea how to solve the problem? Is there any parameter I could use as a key to make a pair?

I'm starting to believe that any solution of combining Flex with Exist does not exist.

Below I have an example of http service difinition in Flex:

    <mx:HTTPService
        id="exampleService"
        url="http://localhost:8080/exist/rest/db/"
        resultFormat="e4x"
        method="POST"
        contentType="application/xml"    (only this and application/x-www-form-urlencoded are allowed values)
        result="onExampleServiceResult(event)">       
        <mx:request xmlns="">
            <exampleKey1>
example value, like xqery code
            </exampleKey1>
        </mx:request>
    </mx:HTTPService>

When I try to remove <exampleKey1> I get an error: Model 'request' contains only scalar content - this is currently unsupported.

This definition works fine (it's GET and doesn't need any parameters):

    <mx:HTTPService
        id="exampleService"
        url="http://localhost:8080/exist/rest/db/clients?_query={query}&amp;_start=1&amp;_howmany={howmany}"
        resultFormat="e4x"
        method="GET"
        result="onExampleServiceResult(event)"/>


Thanks in advance for any help,
Dominik Piekarczyk

On Wed, Jul 2, 2008 at 7:42 PM, Roger Espinosa <roger.espinosa@...> wrote:
How much control do you have in Flex for passing arguments? When constructing REST queries I tend to wrap the XQuery statements in a CDATA block so I don't have to do any encoding.

In your case,

<dateTime>{current-dateTime()}</dateTime>

would simply be

&lt;dateTime>{curretn-dateTime()}&lt;/dateTime>

-R



--
--
Dominik Piekarczyk
www.araneo.pl
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open