PHP5 consume web service without wsdl

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • frustratedcoder

    PHP5 consume web service without wsdl

    I need to consume a web service written in Perl but there is no wsdl
    file for this service.
    The perl soap client that can call and consume this web service looks
    like this (if it helps)

    #!perl -w

    use SOAP::Lite +trace => "debug";

    print SOAP::Lite
    ->uri("urn:WebSe rvices")
    ->proxy("http://example.com")
    ->SomeMethodName ('param1', 'param2')
    ->result;

    How can this be translated in to something that is easily used in PHP5?

    There is no wsdl file describing the web service above.

  • David Haynes

    #2
    Re: PHP5 consume web service without wsdl

    frustratedcoder wrote:[color=blue]
    > I need to consume a web service written in Perl but there is no wsdl
    > file for this service.
    > The perl soap client that can call and consume this web service looks
    > like this (if it helps)
    >
    > #!perl -w
    >
    > use SOAP::Lite +trace => "debug";
    >
    > print SOAP::Lite
    > ->uri("urn:WebSe rvices")
    > ->proxy("http://example.com")
    > ->SomeMethodName ('param1', 'param2')
    > ->result;
    >
    > How can this be translated in to something that is easily used in PHP5?
    >
    > There is no wsdl file describing the web service above.[/color]

    I'm going to assume that you are using the built-in SOAP library (as
    opposed to PEAR or nuSOAP). I'm also going to assume PHP5 and an
    object-oriented approach.

    To instantiate a new SOAP client:

    $client = new SoapClient(null , $args);

    The null indicates that there is no WSDL for this client.

    The args will be something like:
    $args = array(
    'soap_version' => SOAP_1_1,
    'location' => 'http://example.com/?WebServices',
    'uri' => 'http://example.com/'
    );

    Then you can call the methods as:

    $client->SomeMethodName (array('param1' , 'param2'));

    Don't forget to set try-catch blocks to handle exceptions.

    -david-


    Comment

    • frustratedcoder

      #3
      Re: PHP5 consume web service without wsdl

      This was exactly the example I was looking for, thanks.

      Comment

      • frustratedcoder

        #4
        Re: PHP5 consume web service without wsdl

        Now I have the access to the web service, but all Im getting is
        "PCFET0NUWVBFIF N0ZXBTdG9uZUVhc 3lDcnVpdENh"? when I run the client
        written in Perl I get a string of xml in return.

        Comment

        Working...