Re: GsoaP/PEAR::SOAP interoperability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi:

I'm having a similar trouble, I'm using a PHP PEAR::SOAP server (I think it's the same HelloServer from the example) and I'm using a gSoap C++ client to retrieve the answer from it. The problem I have is that when I print the resulting string it's allways empty. I have the answer from the server, so I believe the call is going fine, so could you tell me if I'm doing something wrong on my code? Thanks.

 Server Response:

T 10.1.0.10:80 -> 10.1.0.141:32823 [AP]
 HTTP/1.1 200 OK..Date: Thu, 04 Nov 2004 13:56:30 GMT..Server:
Apache/1.3.26
  (Unix) DAV/1.0.3 PHP/4.3.0..X-Powered-By: PHP/4.3.0..Status: 200
OK..Conte
 nt-Length: 544..Connection: close..Content-Type: text/xml;
charset=UTF-8...
 .<?xml version="1.0" encoding="UTF-8"?>....<SOAP-ENV:Envelope
xmlns:SOAP-E
 NV="http://schemas.xmlsoap.org/soap/envelope/";..
xmlns:xsd="http://www.w3.o
 rg/2001/XMLSchema"..
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";.
 . xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";..
xmlns:ns4="u
 rn:HelloServer"..
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/e
 ncoding/">..<SOAP-ENV:Body>....<ns4:sayHelloResponse>..<return
xsi:type="xs
 d:string">Hello
Mauro</return></ns4:sayHelloResponse>..</SOAP-ENV:Body>..</
 SOAP-ENV:Envelope>..

 Code for the main app:

#include <iostream.h>
#include "soapH.h"
#include "HelloServerBinding.nsmap"

void main( int argc, char * argv[])
{
       struct soap soap;

       soap_init( &soap );
       struct ns1__sayHelloResponse rta;

       char * nombre;

if ( argc > 1 )
{
nombre = argv[1];
}
else
{
cout << "Ingrese un nombre" << endl;
exit(0);
}
rta.outputString = "Hola mundo!";
cout << "Antes: " << rta.outputString << endl;
int rtaSoap = soap_call_ns1__sayHello( &soap, "", "", nombre, rta );
cout << "Despues: " << rta.outputString << endl;
cout << "Respuesta del soap " << rtaSoap << endl;
}



Owain Perry wrote:

Norb,
Sorry not had a chance to reply before, Just using a modified version of the
quote example in the samples directory that comes with Gsoap, I have used a
stuct to return , so you can see how they fit in if you need to pass complex
structures around. Let me know if you have any problems.

This is the c++ header file.
<snip>

typedef char * xsd__string;
int ns__sendback (char * password, struct ns__sendbackResponse {xsd__string
_return_;}  * out);

</snip>

This is the c++ code.
<Snip>

#include "soapH.h" /* include generated proxy and SOAP support */

int main(int argc, char **argv)
{
  struct soap soap;
  struct ns__sendbackResponse q;
  char *sym;
  if (argc > 1)
    sym = argv[1];
  else
  {
    fprintf(stderr, "Usage: quote <ticker>n");
    exit(1);
  }
  soap_init(&soap);
  if (soap_call_ns__sendback(&soap, "http://redfairy/soap/testserver.php";,
"",sym , &q) == 0)
     printf("Input was %s    soap call returned  - %sn", sym, q._return_);
  else
    soap_print_fault(&soap, stderr);
  soap_end(&soap);
  soap_done(&soap);
  return 0;
}

/* The namespace mapping table is required and associates namespace prefixes
with namespace names: */
struct Namespace namespaces[] =
{
  {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/"},    /* MUST be
first */
  {"SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"},    /* MUST be
second */
  {"xsi", "http://www.w3.org/1999/XMLSchema-instance";,
"http://www.w3.org/*/XMLSchema-instance"},       /* MUST be third */
  {"xsd", "http://www.w3.org/1999/XMLSchema";,
"http://www.w3.org/*/XMLSchema"},
  {"ns", "urn:test_Server"},    /* Method namespace URI */
  {NULL, NULL}
};

</snip>

and the php server

<snip>

<?php

// first, include the SOAP/Server class
require_once 'SOAP/Server.php';

class Test1 {
    // Stores instance of PEAR::SOAP Server
    var $soapServer;

    // Constructor builds PEAR::SOAP Server
    function Test1 ()
    {
        // Switch off notices to all GET
        error_reporting(E_ALL ^ E_NOTICE);

        // Instantiate PEAR::SOAP SOAP_Server
        $this->soapServer=new SOAP_Server;

        // Build the object map (using this instance) + add a namespace
        $this->soapServer->addObjectMap($this,'urn:test_Server');

        // Turn on the server
        $this->soapServer->service($GLOBALS['HTTP_RAW_POST_DATA']);
    }

    function serverTimestamp()
    {
        return time();
    }

    function sendback($name)
    {
        return 'Hello '.$name;
    }
}

// Start the SOAP server
$test = new Test1;
?>

</snip>

Have fun

O.





-----Original Message-----
From: PHPDiscuss - PHP Newsgroups and mailing lists
[mailto:nblam@austin.rr.com]
Sent: 04 May 2004 19:12
To: soap@lists.php.net
Subject: Re:  GsoaP/PEAR::SOAP interoperability


Thanks O for answering my posting.

That would be great if you could send me a example (like 'hello' below) of
a GSOAP client making a request to a PEAR::SOAP server.
Also, if you have an example of structures or lists that are being passed
as a SOAP response.  I have a MySQL database that is being queried by my
backend PHP code and am wondering how to pass multiple types via SOAP.

Thanks again,
Norb


Here's the corresponding C code which is currently failing:

C Code:

#include "soapH.h"
#include "ns.nsmap"

const char server[] =
"http://192.168.2.102/test/pear_soap/examples/ws/testserver1.php";;

int main(int argc, char **argv) {
  struct soap soap;
  char result[50];
  char *pass_variable;

pass_variable = result;

soap_init(&soap);

  soap_call_ns4__hello(soap_new(), server, "",  "bonnie girl",
&pass_variable);

  if (soap.error) soap_print_fault(&soap,stderr);
  else {
    printf("successful");
    printf("result: %s", pass_variable);
  }


return 0;

}

Here's the corresponding PHP server side code:

<?php
class Test1 {
    // Stores instance of PEAR::SOAP Server
    var $soapServer;

    // Constructor builds PEAR::SOAP Server
    function Test1 () {
        // Switch off notices to all GET
        error_reporting(E_ALL ^ E_NOTICE);

        // Instantiate PEAR::SOAP SOAP_Server
        $this->soapServer=new SOAP_Server;

// Build the object map (using this instance) + add a namespace

$this->soapServer->addObjectMap($this,'http://www.phppatterns.com#Test1');
        //$this->soapServer->addObjectMap($this,'http://tempuri.org');

        // Turn on the server
        $this->soapServer->service($GLOBALS['HTTP_RAW_POST_DATA']);
    }

    function serverTimestamp() {
        return time();
    }

    function hello($name) {
        return 'Hello '.$name;
    }

    function hello1() {
        return 'Hello from PEAR';
    }
}
?>




Owain Perry wrote:

Norb,

I can confirm that I have got GSOAP 2.4 & 2.5 working fine with
PEAR::Soap,
but I have only been passing strings around and not really tested any
other
data types. Apart from Attachments which don't seem to work that well as
PEAR::SOAP doesn't build the options array that gsoap expects, but this
can
be worked around. let me know if you need some code.

O.

-----Original Message-----
From: PHPDiscuss - PHP Newsgroups and mailing lists
[mailto:nblam@austin.rr.com]
Sent: 27 April 2004 03:00
To: soap@lists.php.net
Subject:  GsoaP/PEAR::SOAP interoperability


I've been trying to get my C++ gsoap client request to work with my PHP
PEAR::SOAP server response.

Has anyone ever tried this and get it to work? Here are the details:

GSOAP request:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:ns4="http://www.phppatterns.com#Test1";>

  <SOAP-ENV:Body id="_0">
    <hello xmlns="http://www.phppatterns.com#Test1";>
      <param-1>bonnie girl</param-1>
    </hello>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

PEAR::SOAP response:

HTTP/1.1 200 OK
Date: Tue, 27 Apr 2004 01:50:52 GMT
Server: Apache/1.3.27 (Unix) PHP/4.3.1 DAV/1.0.3 mod_ssl/2.8.14
OpenSSL/0.9.6b
X-Powered-By: PHP/4.3.1
Status: 200 OK
Content-Length: 561
Connection: close
Content-Type: text/xml; charset=UTF-8

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
 xmlns:xsd="http://www.w3.org/2001/XMLSchema";
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
 xmlns:ns4="http://www.phppatterns.com#Test1";
 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
<SOAP-ENV:Body>

<ns4:helloResponse>
<return xsi:type="xsd:string">Hello bonnie
girl</return></ns4:helloResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Everything looks good except GSOAP doesn't like the <return> tag
according to the following debug message:

Unknown element 'return' (level=3, 1)
IGNORING element 'return'
End element found (level=3) 'return'=''

A more generic question:

Has anyone ever gotten a C++ SOAP client (any SOAP implementation) to
correct communicate with a PHP SOAP Server (Any SOAP implementation)

Thanks in Advance

Norb

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Soap Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux