Add new method to a Spray service

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Add new method to a Spray service

bmurphy
I added the following method to the Demo class:
    newMessage
        "answer xsd:string"
        ^'new message'

and then evaluated:
    DemoService new storeOperationPort.    "to load the newMessage into the
WSDL"
    client := DemoService new createClientTo: 'http://localhost/hibye'.
    (client send: 'hi') value       "returns    'hello, world'"
    (client sned: 'newMessage') value

the last line produces a walkback with this error:
    a SoapSendFault('Can not locate the handler for: m:newMessage
#''http://www.soaplite.com/Demo''')

Looking on the class side of Demo, there is one method:
    sprayPortNamespace
        ^#'http://www.soaplite.com/Demo'

Since it appears to be looking on the web for the method definition, I tried
deleting this method, but then got a walkback on the 'hi' message--it no
longer knows about any of the messages! Here is the walkback error:
    a SoapSendFault('Can not locate the handler for: m:hi #urn:Demo')

Anyone know how to grab the local defintion?

Thanks in advance, Brian Murphy-Dye


Reply | Threaded
Open this post in threaded view
|

Re: Add new method to a Spray service

Steve Waring-2
Hi Brian,

I can not see anything wrong with your code, but I think your problem was
that you needed to flush and restart Swazoo for the definition changes to
take effect.

I would suggest the following steps when altering the definition of a
service;

1/ Ensure that Swazoo is not serving by evaluating "SwazooSiteRegistry
flush".

2/ Add your new method and then evaluate "DemoService new
storeOperationPort". (This evaluation does a limited form of validation of
the service and should root out any errors). For the Beta1, all public
methods of the class are analyzed. (This is changed to a separate category
in a future release to avoid confusion).

3/ For a quick check that the definition is what you expect, evaluate
"DemoService new viewLocalWSDL". This will open a browser on the WSDL. You
should see references to a "newMessage" operation.

4/ Create a server by evaluating "SwazooSiteScript startUpOn:
(SpSwazooServiceResource uriPattern: 'hibye' service: DemoService new)."
Once you have done this, in a browser go to http://localhost/hibye and you
should see the "newMessage" operation listed.

5/ Create a client by evaluating "client := DemoService new createClientTo:
'http://localhost/hibye'" Once you have done this, send client the message
#operationNames, and again you should see "newMessage" as an operation name.


I think that all you were missing was step 1/, but the remaining steps are
useful feedback. If you are still having problems, can you fileout the Demo
and DemoService classes and email them to me.

> the last line produces a walkback with this error:
>     a SoapSendFault('Can not locate the handler for: m:newMessage
> #''http://www.soaplite.com/Demo''')

A Spray server dispatches incoming soap messages by qualified name, in this
case "newMessage" qualified in the namespace http://www.soaplite.com/Demo
.The namespace identifies the receiver instance, and the localName
identifies the method. Because the server had not been created after the
DemoService definition change, it did not know about the new "newMessage"
operation.

> Looking on the class side of Demo, there is one method:
>     sprayPortNamespace
>         ^#'http://www.soaplite.com/Demo'
>
> Since it appears to be looking on the web for the method definition

The use of http urls as xml namespaces is a controversial but common
practice. It implies nothing about what the url resolves to, or even if it
resolves at all. I implemented this service to be the same as an existing
3rd party service, and this was the namespace they used.

As a general rule in Spray, traditional urls are strings, namespaces are
symbols.

As long as you are creating both the client and the server from the same
service, it will not matter whether this namespace is
#'http://www.soaplite.com/Demo' or #urn:Demo or #http://AnythingYouLike/. A
good practice is to use a domain name that you own for your namespaces to
minimize potential clashes.

FWIW: There is some info on debugging a service at:
http://www.dolphinharbor.org:8080/SprayDocumentation/28#Q28

Hope this helps!
Steve Waring
www.dolphinharbor.org










"bmurphy" <[hidden email]> wrote in message
news:a50d35$etg$[hidden email]...
> I added the following method to the Demo class:
>     newMessage
>         "answer xsd:string"
>         ^'new message'
>
> and then evaluated:
>     DemoService new storeOperationPort.    "to load the newMessage into
the

> WSDL"
>     client := DemoService new createClientTo: 'http://localhost/hibye'.
>     (client send: 'hi') value       "returns    'hello, world'"
>     (client sned: 'newMessage') value
>
> the last line produces a walkback with this error:
>     a SoapSendFault('Can not locate the handler for: m:newMessage
> #''http://www.soaplite.com/Demo''')
>
> Looking on the class side of Demo, there is one method:
>     sprayPortNamespace
>         ^#'http://www.soaplite.com/Demo'
>
> Since it appears to be looking on the web for the method definition, I
tried
> deleting this method, but then got a walkback on the 'hi' message--it no
> longer knows about any of the messages! Here is the walkback error:
>     a SoapSendFault('Can not locate the handler for: m:hi #urn:Demo')
>
> Anyone know how to grab the local defintion?
>
> Thanks in advance, Brian Murphy-Dye
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Add new method to a Spray service

bmurphy
Steve,

Thanks for the quick and detailed reply--you were correct that I omitted the
first step. Life is good again. By the way, you've done a nice port. It's
great to be able to do web services from Dolphin ;-)

Brian.

"Steve Waring" <[hidden email]> wrote in message
news:a50uh1$3q6i5$[hidden email]...

> Hi Brian,
>
> I can not see anything wrong with your code, but I think your problem was
> that you needed to flush and restart Swazoo for the definition changes to
> take effect.
>
> I would suggest the following steps when altering the definition of a
> service;
>
> 1/ Ensure that Swazoo is not serving by evaluating "SwazooSiteRegistry
> flush".
>
> 2/ Add your new method and then evaluate "DemoService new
> storeOperationPort". (This evaluation does a limited form of validation of
> the service and should root out any errors). For the Beta1, all public
> methods of the class are analyzed. (This is changed to a separate category
> in a future release to avoid confusion).
>
> 3/ For a quick check that the definition is what you expect, evaluate
> "DemoService new viewLocalWSDL". This will open a browser on the WSDL. You
> should see references to a "newMessage" operation.
>
> 4/ Create a server by evaluating "SwazooSiteScript startUpOn:
> (SpSwazooServiceResource uriPattern: 'hibye' service: DemoService new)."
> Once you have done this, in a browser go to http://localhost/hibye and you
> should see the "newMessage" operation listed.
>
> 5/ Create a client by evaluating "client := DemoService new
createClientTo:
> 'http://localhost/hibye'" Once you have done this, send client the message
> #operationNames, and again you should see "newMessage" as an operation
name.
>
>
> I think that all you were missing was step 1/, but the remaining steps are
> useful feedback. If you are still having problems, can you fileout the
Demo
> and DemoService classes and email them to me.
>
> > the last line produces a walkback with this error:
> >     a SoapSendFault('Can not locate the handler for: m:newMessage
> > #''http://www.soaplite.com/Demo''')
>
> A Spray server dispatches incoming soap messages by qualified name, in
this

> case "newMessage" qualified in the namespace http://www.soaplite.com/Demo
> .The namespace identifies the receiver instance, and the localName
> identifies the method. Because the server had not been created after the
> DemoService definition change, it did not know about the new "newMessage"
> operation.
>
> > Looking on the class side of Demo, there is one method:
> >     sprayPortNamespace
> >         ^#'http://www.soaplite.com/Demo'
> >
> > Since it appears to be looking on the web for the method definition
>
> The use of http urls as xml namespaces is a controversial but common
> practice. It implies nothing about what the url resolves to, or even if it
> resolves at all. I implemented this service to be the same as an existing
> 3rd party service, and this was the namespace they used.
>
> As a general rule in Spray, traditional urls are strings, namespaces are
> symbols.
>
> As long as you are creating both the client and the server from the same
> service, it will not matter whether this namespace is
> #'http://www.soaplite.com/Demo' or #urn:Demo or #http://AnythingYouLike/.
A

> good practice is to use a domain name that you own for your namespaces to
> minimize potential clashes.
>
> FWIW: There is some info on debugging a service at:
> http://www.dolphinharbor.org:8080/SprayDocumentation/28#Q28
>
> Hope this helps!
> Steve Waring
> www.dolphinharbor.org
>
>
>
>
>
>
>
>
>
>
> "bmurphy" <[hidden email]> wrote in message
> news:a50d35$etg$[hidden email]...
> > I added the following method to the Demo class:
> >     newMessage
> >         "answer xsd:string"
> >         ^'new message'
> >
> > and then evaluated:
> >     DemoService new storeOperationPort.    "to load the newMessage into
> the
> > WSDL"
> >     client := DemoService new createClientTo: 'http://localhost/hibye'.
> >     (client send: 'hi') value       "returns    'hello, world'"
> >     (client sned: 'newMessage') value
> >
> > the last line produces a walkback with this error:
> >     a SoapSendFault('Can not locate the handler for: m:newMessage
> > #''http://www.soaplite.com/Demo''')
> >
> > Looking on the class side of Demo, there is one method:
> >     sprayPortNamespace
> >         ^#'http://www.soaplite.com/Demo'
> >
> > Since it appears to be looking on the web for the method definition, I
> tried
> > deleting this method, but then got a walkback on the 'hi' message--it no
> > longer knows about any of the messages! Here is the walkback error:
> >     a SoapSendFault('Can not locate the handler for: m:hi #urn:Demo')
> >
> > Anyone know how to grab the local defintion?
> >
> > Thanks in advance, Brian Murphy-Dye
> >
> >
>
>