Loading ...
Sorry, an error occurred while loading the content.

Re: SOLUTION: [soaplite] SOAP::Lite server with .NET client - SOAPAction woes

Expand Messages
  • Donald Chen
    Issac, Thanks for the WSDL explanation. I was not quite clear about WSDL stuff. It turns out that after a bit tweaks on the way to invoke the service on the
    Message 1 of 8 , Aug 13, 2004
    • 0 Attachment
      Issac,

      Thanks for the WSDL explanation. I was not quite clear about WSDL stuff.

      It turns out that after a bit tweaks on the way to invoke the service on the client, it works.
      (Frankly, I am still do not know why it works). Here are the version which works:

      -------------------------------------8<-----------------------------
      1. package samples.userguide.example1;

      2. import org.apache.axis.client.Call;
      3. import org.apache.axis.client.Service;
      4. import javax.xml.namespace.QName;

      5. public class TestClient {
      6. public static void main(String [] args) {
      7. String ret = "1";
      8. try {
      9. String endpoint = "http://locahost:8003/echoYaDaemon";
      10.
      11. Service service = new Service();
      12. Call call = (Call) service.createCall();
      13.
      14. call.setTargetEndpointAddress( new java.net.URL(endpoint) );
      15. call.setOperationName(new QName("urn:EchoYa", "echoYa"));
      16. call.setUseSOAPAction(true);
      17. call.setSOAPActionURI("urn:EchoYa#echoYa");
      18.
      19. ret = (String) call.invoke( new Object[] { args[0] } );
      20.
      21. System.out.println("Sent " + args[0] + ", got '" + ret + "'");
      22. } catch (Exception e) {
      23. System.err.println(e.toString());
      24. }
      25. }
      26. }
      -------------------------------------8<-----------------------------
      As you can see, line 15 and 16 are the ones been altered.

      As for the exporting/importing the method on the service dispatcher, I tried both with
      exporting/importing and the without them. They do not make difference.

      Thanks again,

      Donald
      --- Issac Goldstand <margol@...> wrote:

      > First of all, as Mark already mentioned, you don't write a WSDL "server".
      > WSDL is a document which describes the web service, much like DTDs were used
      > for XML (I think XML Schema's are too complex to make an accurate
      > comparison). Many WS server toolkits help out by generating WSDL for you.
      > SOAP::Lite is, unfortunately, not one of those. WSDL needs to be written
      > the old fashined way - using your favorite text editor.
      >
      > As o the error message, I'm no expert on the SOAP::Lite dispatcher, but it
      > seems to me that the fact that you're exporting the function into the "main"
      > namespace may be confusing it. The dispatcher may come across the "echoYa"
      > method in the "main" namespace first, and send that to the HTTP::Server
      > object to test against the SOAPAction header. Thus, it wouldn't see
      > EchoYa::echoYa as being correct, and spitting that error. Try not
      > exporting/importing symbols to see if that works. (It would also be
      > interesting if you tried calling main::echoYa and seeing if that worked
      > better).
      >
      > Hope that helps a bit,
      > Issac
      >
      >
      >
      > ----- Original Message -----
      > From: "wxyc" <wxyc@...>
      > To: <soaplite@yahoogroups.com>
      > Sent: Thursday, August 12, 2004 6:16 PM
      > Subject: Re: SOLUTION: [soaplite] SOAP::Lite server with .NET client -
      > SOAPAction woes
      >
      >
      > > Issac -
      > >
      > > I am having a similar problem on making a client(in Axis/Java 1.1)
      > > call a SOAP::Lite server, and your post is helpful.
      > >
      > > However, by following your advices, the problem is not gone.
      > >
      > > My WS server is deployed in the static mode and is not a WSDL-type
      > > server . Here is the code:
      > >
      > > --------------------8<-----------------------
      > > #! /usr/local/bin/perl -w
      > > use SOAP::Transport::HTTP;
      > > use lib ("/nas/dev/test/testSoap/");
      > > use EchoYa qw(echoYa);
      > >
      > > $SIG{PIPE} = $SIG{INT} = 'IGNORE';
      > >
      > > $daemon = SOAP::Transport::HTTP::Daemon
      > > -> new (LocalPort => 8003)
      > > -> dispatch_to('EchoYa');
      > > $daemon->handle;
      > > --------------------8<-----------------------
      > >
      > > The EchoYa.pm is like this:
      > > --------------------8<-----------------------
      > > package EchoYa;
      > >
      > > require Exporter;
      > > @ISA = qw(Exporter);
      > > @EXPORT = qw( echoYa );
      > >
      > > sub echoYa {
      > > print "enter echoYa\n";
      > > my $self = shift;
      > > my $ya = shift;
      > > return "I got $ya!";
      > > }
      > > 1;
      > > --------------------8<-----------------------
      > >
      > > I changed the relevent line of the client to set the SOAPAction as
      > > "urn:EchoYa#echoYa", I still got an error:
      > >
      > > SOAPAction shall match 'uri#method' if present (got
      > > 'urn:EchoYa#echoYa', expected '#echoYa'
      > >
      > > You post sounds like you have a WSDL serveice written in SOAP::Lite.
      > > How did you do that? because SOAP::Lite does not really provide bolts
      > > and nuts for writing a WSDL server?
      > >
      > > Thanks,
      > >
      > > Donald
      > >
      > > --- In soaplite@yahoogroups.com, "Issac Goldstand" <margol@b...>
      > > wrote:
      > > > MessageThanks for all the suggestions. I will attempt to include
      > > lots of details in this response for the sake of the archives.
      > > >
      > > > My original suspicion was that the MS type namespaces (eg / instead
      > > of #, or "s or lack thereof, or urn: or http:, etc) were not the
      > > issue, as the *server* is the part that cares about the namespace, and
      > > to properly create a proxy from WSDL, any toolkit regardless of the
      > > underlying framwork, need to take the WSDL and just *do what it says*
      > >
      > > >
      > > > Futher, using "urn:MyApp" tends to be important when talking to
      > > SOAP::Lite, using the format of "urn:Foo/Bar#baz" may be important,
      > > simply because when dispatching (I think both dynamicly and staticly)
      > > the SOAP calls to the actually methods, SOAP::Lite translates
      > > everything between "urn:" and "#" to the class, substituting "/" for
      > > "::", and everything after "#" as the method name. For example:
      > > > soapAction="urn:Foo/Bar#Baz" becomes Foo::Bar::baz (or baz in
      > > package Foo::Bar if that wasn't clear)
      > > > soapAction="urn:MyApp#Method" becomes MyApp::Method
      > > > etc
      > > >
      > > > Also, there are lots of mentions in the archives and in the
      > > SOAP::Lite docs seemingly saying that MS doesn't play nicely with RPC
      > > type operations, but I've encoutnered no problems with it; quite the
      > > opposite.
      > > >
      > > > As it turns out, my problem was that MS requires the namespace to be
      > > explicitly defined wherever possible. In my final (working) WSDL, the
      > > namespace of wsdl had to be set to "urn:MyApp" (I also set
      > > targetNamespace to "urn:MyApp"), and each "main" section needed to be
      > > fully qualified (see below for snippet). Additionally, in the
      > > bindings section, each operation's input/output/etc "body" needs to
      > > have the namespace fully qualified (eg < soap:body "urn:MyApp:Method"
      > > ... />)
      > > >
      > > > Also, make sure to use UTF-8, as I sometimes had crashes when
      > > talking utf-16 to SOAP::Lite from MS...
      > > >
      > > > the WSDL structure should thus be as follows:
      > > >
      > > > <?xml version="1.0" encoding="UTF-8"?>
      > > > <wsdl:definitions name="MyApp" targetNamespace="urn:MyApp"
      > > xmlns="urn:MyApp" xmlns:tns="urn:MyApp"
      > > xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      > > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      > > xmlns:xsd="http://www.w3.org/2001/XMLSchema" ... >
      > > > <wsdl:message name="MethodRequest">
      > > > <wsdl:part name="somePart" type="xsd:string"/>
      > > > ...
      > > > </wsdl:message>
      > > > <wsdl:portType name="MyAppPortType">
      > > > <wsdl:operation name="Method">
      > > > <wsdl:input message="tns:MethodRequest"/>
      > > > <wsdl:output message="tns:MethodResponse"/>
      > > > </wsdl:operation>
      > > > ...
      > > > </wsdl:portType>
      > > > <wsdl:binding name="MyAppBinding" type="tns:MyAppPortType">
      > > > <soap:binding style="rpc"
      > > transport="http://schemas.xmlsoap.org/soap/http"/>
      > > > <wsdl:operation name="Method">
      > > > <soap:operation soapAction="urn:MyApp#Method"
      > > style="rpc"/>
      > > > <wsdl:input>
      > > > <soap:body namespace="urn:MyApp" use="literal"/>
      > > > </wsdl:input>
      > > > <wsdl:output>
      > > > <soap:body namespace="urn:MyApp" use="literal"/>
      > > > </wsdl:output>
      > > > </wsdl:operation>
      > > > ...
      > > > </wsdl:binding>
      > > > <wsdl:service name="MyApp">
      > > > <wsdl:port binding="tns:MyAppBinding" name="MyAppPort">
      > > > <soap:address location="http://localhost:8082"/>
      > > > </wsdl:port>
      > > > </wsdl:service>
      > > > </wsdl:definitions>
      > > >
      > > > One everything was all nice and fully-qualified, it seemed to work
      > > fine in .NET 1.x
      > > > I'm currently playing with it on the new beta of 2.0, but I think
      > > it's all good there too
      > > >
      > > > Issac
      > > >
      > > > ----- Original Message -----
      > > > From: Maurice McCabe
      > > > To: soaplite@yahoogroups.com
      > > > Sent: Friday, July 16, 2004 9:44 PM
      > > > Subject: RE: [soaplite] SOAP::Lite server with .NET client -
      > > SOAPAction woes
      > > >
      > > >
      > > > I have created a .NET client that talks to a SOAP::Lite server
      > > (using simple and complex types in either direction)
      > > >
      > > > > SOAP::Serializer::envelope: Client SOAPAction shall match
      > > 'uri#method' if
      > > > > present (got 'urn:MyApp#Method)
      > > >
      > > > -----Original Message-----
      > > > From: jgr@p... [mailto:jgr@p...] On Behalf Of Klaus Guenter
      > > > Sent: Friday, July 16, 2004 4:43 AM
      > > > To: soaplite@yahoogroups.com
      > > > Subject: Re: [soaplite] SOAP::Lite server with .NET client -
      > > SOAPAction woes
      > > >
      > > >
      > > > Hi!
      > > >
      > > > On Tuesday 13 July 2004 15:44, Issac Goldstand wrote:
      > > > > If I explicitly declare the SOAPAction in the WSDL, I get:
      > > > > SOAP::Serializer::envelope: Client SOAPAction shall match
      >
      === message truncated ===




      __________________________________
      Do you Yahoo!?
      New and Improved Yahoo! Mail - Send 10MB messages!
      http://promotions.yahoo.com/new_mail
    Your message has been successfully submitted and would be delivered to recipients shortly.