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

replace namesp1 from method call?

Expand Messages
  • Rich
    How do I replace the namespace (namesp1) in the method call with something simpler, like ns ? Here s the perl I m using: my $results =
    Message 1 of 4 , Apr 22, 2003
    • 0 Attachment
      How do I replace the namespace (namesp1) in the method call with
      something simpler, like "ns"? Here's the perl I'm using:

      my $results = $soap->getAllPendingDocumentInfo(SOAP::Data
      ->name("merchant")
      ->type("ns:Merchant")
      ->value(
      \SOAP::Data->value(
      SOAP::Data->name("merchantName" => "1922"),
      SOAP::Data->name("merchantIdentifier" => "1922")
      ->type("ns:MerchantIdentifier"),
      ) ),
      SOAP::Data->name("messageType" => "_GET_ORDERS_DATA_")
      ->type("ns:MessageType")
      );

      Here's the XML it generates:

      <namesp1:getAllPendingDocumentInfo
      xmlns:namesp1="nsMerchantDataExchange">
      <merchant xsi:type="ns:Merchant">
      <merchantName xsi:type="xsd:string">1922</merchantName>
      <merchantIdentifier
      xsi:type="ns:MerchantIdentifier">1922</merchantIdentifier>
      </merchant>
      <messageType xsi:type="ns:MessageType">_GET_ORDERS_DATA_</messageType>
      </namesp1:getAllPendingDocumentInfo>
      </SOAP-ENV:Body></SOAP-ENV:Envelope>


      thanks in advance!
      -Rich
    • Byrne Reese
      Try this: my $method = SOAP::Data- name( getAllPendingDocumentInfo) - uri( ns ); my $results = $soap- call($method = SOAP::Data - name( merchant )
      Message 2 of 4 , Apr 22, 2003
      • 0 Attachment
        Try this:
         
        my $method = SOAP::Data->name("getAllPendingDocumentInfo)
                               ->uri("ns");
         
        my $results = $soap->call($method =>
                         SOAP::Data
                           ->name("merchant")
                           ->type("ns:Merchant")
                           ->value(
                \SOAP::Data->value(
                 SOAP::Data->name("merchantName" => "1922"),
                 SOAP::Data->name("merchantIdentifier" => "1922")
                           ->type("ns:MerchantIdentifier"),
                            ) ),
                 SOAP::Data->name("messageType" => "_GET_ORDERS_DATA_")
                           ->type("ns:MessageType")
                            );

        -----Original Message-----
        From: Rich [mailto:krush_groover@...]
        Sent: Tuesday, April 22, 2003 4:09 PM
        To: soaplite@yahoogroups.com
        Subject: [soaplite] replace namesp1 from method call?

        How do I replace the namespace (namesp1) in the method call with
        something simpler, like "ns"?  Here's the perl I'm using:

        my $results = $soap->getAllPendingDocumentInfo(SOAP::Data
                           ->name("merchant")
                           ->type("ns:Merchant")
                           ->value(
                \SOAP::Data->value(
                 SOAP::Data->name("merchantName" => "1922"),
                 SOAP::Data->name("merchantIdentifier" => "1922")
                           ->type("ns:MerchantIdentifier"),
                            ) ),
                 SOAP::Data->name("messageType" => "_GET_ORDERS_DATA_")
                           ->type("ns:MessageType")
                            );

        Here's the XML it generates:

        <namesp1:getAllPendingDocumentInfo
        xmlns:namesp1="nsMerchantDataExchange">
        <merchant xsi:type="ns:Merchant">
              <merchantName xsi:type="xsd:string">1922</merchantName>
              <merchantIdentifier
        xsi:type="ns:MerchantIdentifier">1922</merchantIdentifier>
        </merchant>
        <messageType xsi:type="ns:MessageType">_GET_ORDERS_DATA_</messageType>
        </namesp1:getAllPendingDocumentInfo>
        </SOAP-ENV:Body></SOAP-ENV:Envelope>


        thanks in advance!
        -Rich




        To unsubscribe from this group, send an email to:
        soaplite-unsubscribe@yahoogroups.com



        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
      • Rich
        Thanks Byrne, you got me started on it, ya might have made a typo though so here is my final result for posterity (note prefix and uri change in method: my
        Message 3 of 4 , Apr 23, 2003
        • 0 Attachment
          Thanks Byrne, you got me started on it, ya might have made a typo
          though so here is my final result for posterity (note prefix and uri
          change in method:

          my $method = SOAP::Data->name("getAllPendingDocumentInfo")
          ->uri("nsMerchantDataExchange")
          ->prefix("ns");
          my $results = $soap->call($method => (SOAP::Data
          ->name("merchant")
          ->type("ns:Merchant")
          ->value(
          \SOAP::Data->value(
          SOAP::Data->name("merchantName" => "1922"),
          SOAP::Data->name("merchantIdentifier" => "1922")
          ->type("ns:MerchantIdentifier"),
          ) ),
          SOAP::Data->name("messageType" => "_GET_ORDERS_DATA_")
          ->type("ns:MessageType")
          ) );

          and the XML on the wire is:

          <SOAP-ENV:Body>
          <ns:getAllPendingDocumentInfo xmlns:ns="nsMerchantDataExchange">
          <merchant xsi:type="ns:Merchant">
          <merchantName xsi:type="xsd:string">1922</merchantName>
          <merchantIdentifier
          xsi:type="ns:MerchantIdentifier">1922</merchantIdentifier>
          </merchant>
          <messageType
          xsi:type="ns:MessageType">_GET_ORDERS_DATA_</messageType>
          </ns:getAllPendingDocumentInfo>
          </SOAP-ENV:Body>
          </SOAP-ENV:Envelope>


          --- In soaplite@yahoogroups.com, Byrne Reese <breese@g...> wrote:
          > Try this:
          >
          > my $method = SOAP::Data->name("getAllPendingDocumentInfo)
          > ->uri("ns");
          >
          > my $results = $soap->call($method =>
          > SOAP::Data
          > ->name("merchant")
          > ->type("ns:Merchant")
          > ->value(
          > \SOAP::Data->value(
          > SOAP::Data->name("merchantName" => "1922"),
          > SOAP::Data->name("merchantIdentifier" => "1922")
          > ->type("ns:MerchantIdentifier"),
          > ) ),
          > SOAP::Data->name("messageType" => "_GET_ORDERS_DATA_")
          > ->type("ns:MessageType")
          > );
          >
          >
          > -----Original Message-----
          > From: Rich [mailto:krush_groover@y...]
          > Sent: Tuesday, April 22, 2003 4:09 PM
          > To: soaplite@yahoogroups.com
          > Subject: [soaplite] replace namesp1 from method call?
          >
          >
          > How do I replace the namespace (namesp1) in the method call with
          > something simpler, like "ns"? Here's the perl I'm using:
          >
          > my $results = $soap->getAllPendingDocumentInfo(SOAP::Data
          > ->name("merchant")
          > ->type("ns:Merchant")
          > ->value(
          > \SOAP::Data->value(
          > SOAP::Data->name("merchantName" => "1922"),
          > SOAP::Data->name("merchantIdentifier" => "1922")
          > ->type("ns:MerchantIdentifier"),
          > ) ),
          > SOAP::Data->name("messageType" => "_GET_ORDERS_DATA_")
          > ->type("ns:MessageType")
          > );
          >
          > Here's the XML it generates:
          >
          > <namesp1:getAllPendingDocumentInfo
          > xmlns:namesp1="nsMerchantDataExchange">
          > <merchant xsi:type="ns:Merchant">
          > <merchantName xsi:type="xsd:string">1922</merchantName>
          > <merchantIdentifier
          > xsi:type="ns:MerchantIdentifier">1922</merchantIdentifier>
          > </merchant>
          > <messageType
          xsi:type="ns:MessageType">_GET_ORDERS_DATA_</messageType>
          > </namesp1:getAllPendingDocumentInfo>
          > </SOAP-ENV:Body></SOAP-ENV:Envelope>
          >
          >
          > thanks in advance!
          > -Rich
          >
          >
          >
          >
          > Yahoo! Groups Sponsor
          >
          >
          <http://rd.yahoo.com/M=249982.3179269.4495679.1728375/D=egroupweb/S=17
          057010
          > 14:HM/A=1524963/R=0/*http://hits.411web.com/cgi-bin/autoredir?
          camp=556&linei
          > d=3179269&prop=egroupweb&pos=HM>
          >
          > <http://us.adserver.yahoo.com/l?
          M=249982.3179269.4495679.1728375/D=egroupmai
          > l/S=:HM/A=1524963/rand=141278554>
          >
          > To unsubscribe from this group, send an email to:
          > soaplite-unsubscribe@yahoogroups.com
          >
          >
          >
          > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
          > <http://docs.yahoo.com/info/terms/> .
        • Byrne Reese
          Last week I showed how to override the root element of a request, but did not show a way to do the same thing for the root element of a response. So, read on
          Message 4 of 4 , Apr 30, 2003
          • 0 Attachment
            Last week I showed how to override the root element of a request, but did
            not show a way to do the same thing for the root element of a response. So,
            read on if you would like to know how to modify the response's namespace,
            namespace prefix, encoding style, etc. It is not very intuitive, or pretty
            for that matter, but at least it is relatively simple.

            The key in overriding properties of the root element of the response is to
            write a customer serializer. What is a serializer? A serializer converts
            abstract data into a format that can more easily be transmitted between
            endpoints. In this case, a serializer converts scalar and complex data into
            XML. By writing our own serializer we can tell SOAP::Lite how to construct
            the XML representing the response.

            To create a custom serializer, you need to know a little bit about Perl OOP
            (Object Oriented Programing) and inheritence. The following code block shows
            a custom serializer which inherits all properties and behavior from the
            default SOAP::Lite Serializer, but overrides one of its methods/subroutines
            with its own:

            package MySerializer;
            @MySerializer::ISA = 'SOAP::Serializer';
            sub envelope {
            $_[2] =
            SOAP::Data->name($_[2])->prefix('temp')->uri('urn:TemperatureService')
            if $_[1] =~ /^(?:method|response)$/;
            shift->SUPER::envelope(@_);
            }

            This is just a simple serializer, one that changes the root element only,
            but a serializer could be used to serialize any part of a message (in this
            case a response).

            You can save your serializer to its own file (in the form of a perl module),
            and then 'use' it. Or alternatively, you can encapsulate the package in a
            BEGIN { } block anywhere in your code. Either way, to tell SOAP::Lite to use
            your serializer as opposed to its own, you will need to do the following
            within your Web service instance:

            SOAP::Transport::HTTP::CGI
            ->serializer(MySerializer->new)
            ->dispatch_to('MyService')
            ->handle;

            The full source code for a service that overrides the root element as
            described above can be found here:
            http://www.majordojo.com/soaplite/examples/customserializer.txt

            I have also posted the answer to your question in my blog:
            http://www.majordojo.com/archives/2003_04.html#000013

            -----Original Message-----
            From: Torsten Mangner [mailto:tmangner@...]
            Sent: Wednesday, April 30, 2003 1:43 AM
            To: Byrne Reese
            Subject: Re: replace namesp1 from method call?


            --- In soaplite@yahoogroups.com, Byrne Reese <breese@g...> wrote:
            > Try this:
            >
            > my $method = SOAP::Data->name("getAllPendingDocumentInfo)
            > ->uri("ns");
            >
            > my $results = $soap->call($method ... )

            ok this works great for sending method calls to the server ... but how
            about the returning values?

            I tried the following, but this has no effect :(

            return SOAP::Data->name('GetCatalogResponse')
            ->prefix('cat')
            ->uri('urn://catalog')
            ->value(...)

            Any suggestions?

            Thanks in advance,
            Torsten
          Your message has been successfully submitted and would be delivered to recipients shortly.