Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Consuming a .NET webservice

    I am a ASP developer who has a client wishing to consume my webservice. The client's site is coded in PHP, and running on a Unix server. After days of trying to learn PHP, XML_RPC, NuSOAP, and PEAR, I admit I am lost.

    I create a simple test webservice hoping one of you PHP gurus could show me how to consume it.

    The webserviec is located at:
    http://www.astro-matchmaker.com/aspn...mple_Test.asmx

    NameSpace is: ns.www.astromatchmaker.com
    Class name is: Simple_test
    Method name is: test
    The method takes two parameters: strFirstName, strLastName
    The method returns a string.

    Any help would be greatly appreicated!

    Thanks, Rob
    http://www.handlerassociates.com
    It's all about e-fficient solutions

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,058
    Thanks
    10
    Thanked 96 Times in 94 Posts
    HI , never touched a .NET web-service , but firstly nusoap is probably the best option as it has no dependencies (like PEAR::SOAP) nor requires any server extensions..

    now this might be expected to work or return something , but I got no response from your server , unless of course you are only allowing local requests ...

    PHP Code:
    <?php
    require_once('nusoap.php');

    $param = array('strFirstName'=>'rodney','strLastName'=>'redhat');
    $serverpath ='www.astro-matchmaker.com/aspnet_sample/Simple_Test.asmx';
    $namespace="ns.[url]www.astromatchmaker.com/test[/url]";

    $client = new soapclient$serverpath );
    $client->debug_flag=true;

    $yaks$client->call'test' $param $namespace ) ;

    echo 
    $client->error_str;
    print_r($yaks);

    unset(
    $client);
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    $param is empty

    Thanks for the response. We are bothing thinking along the same lines. Below you will see the code I cobbled together. It contacts the service, but my $param array sends nothing; therefore, I don't receive the right response which should contain the two variables I am passing, namely, Frist name and Last Name.

    <?php
    require_once('NuSOAP/nusoap-0.6.1/nusoap.php');
    $client = new soapclient('http://www.astro-matchmaker.com/aspnet_sample/Simple_Test.asmx?wsdl', 'wsdl');

    $param = array('strFirstName'=>'dory','strLastName'=>'Mory');

    $namespace = "urn:ns_www.astromatchmaker.com";
    $response = $client->call("test", $param, $namespace);

    // Display the request and response
    echo '<h2>Request</h2>';
    echo '' . htmlspecialchars($client->request, ENT_QUOTES) . '';
    echo '<h2>Response</h2>';
    echo '' . htmlspecialchars($client->response, ENT_QUOTES) . '';



    // if a fault occurred, output error info
    if (isset($fault)) {
    print "Error: ". $fault;
    }
    else {
    print "no errors";
    }

    print "<BR>";
    print 'The response is:<pre>';
    print "</pre><br>";
    print(htmlentities($response));


    // kill object
    unset($client);




    ?>
    http://www.handlerassociates.com
    It's all about e-fficient solutions

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,058
    Thanks
    10
    Thanked 96 Times in 94 Posts
    ok , well this works , whether the fact that nusoap does not format the request correctly is due to a nusoap internal issue or your wsdl I could not say (perhaps fire them off a mail ?) , but sending the body of the request itself seems to work if a little more verbose !

    PHP Code:
    <?php
    require_once('nusoap.php') ;
    $client = new soapclient('http://www.astro-matchmaker.com/aspnet_sample/Simple_Test.asmx?wsdl' true ) ;
    $msg '
    <test xmlns="ns.[url]www.astromatchmaker.com[/url]">
        <strFirstName>Rodney</strFirstName>
        <strLastName>Redhat</strLastName>
    </test>
    '
    ;
    $response $client->call"test" , array($msg) ) ;

    // Display the request and response
    echo '<h2>Request</h2>';
    echo 
    '' htmlspecialchars($client->requestENT_QUOTES) . '';
    echo 
    '<h2>Response</h2>';
    echo 
    '' htmlspecialchars($client->responseENT_QUOTES) . '';

    if ( isset( 
    $fault ) ) {
        print 
    "Error: "$fault;
    }else{
        print 
    "no errors";
    }
    echo 
    "<br /> <br />The response is " $response ;
    unset(
    $client);
    ?>
    Last edited by firepages; 01-02-2004 at 06:42 AM.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,058
    Thanks
    10
    Thanked 96 Times in 94 Posts
    errr sorry about the urls getting parsed by the BB , I told it not to but I got ignored

    so that should be
    <test xmlns="ns.www.astromatchmaker.com">
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •