2

Good day, reader.

I've been tasked with building a PHP SOAP server to recieve a xml sent by a VB client via WinHttp.WinHttpRequest Object. I am using nuSoap for the php server and it has yet to work until now.

The xml that the vb client sent contain the defined webservice which need to be consumed along with other nessecary variable, which is why theres no soapaction stuff planted inside vb code. 'They' want it this way :'(

The soap server did sent a respond to vb like this :

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  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/">
<SOAP-ENV:Body>
    <SOAP-ENV:Fault>
        <faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode>
        <faultactor xsi:type="xsd:string"></faultactor>
        <faultstring xsi:type="xsd:string">Operation &apos;&apos; is not defined in the WSDL for this service</faultstring>
        <detail xsi:type="xsd:string"></detail>
    </SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The vb client that sent the xml :

Private Sub Command2_Click()
 mydata = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
  mydata = mydata & "<root>" & vbCrLf
mydata = mydata & "<SERVICE>SayHello</SERVICE>" & vbCrLf
mydata = mydata & "<NAME>Noobula</NAME>" & vbCrLf
mydata = mydata & "</root>" & vbCrLf
  Set w = CreateObject("WinHttp.WinHttpRequest.5.1")
      w.Open "POST", "http://127.0.0.1:80/soapvb/terimaxml.php"
      w.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
      w.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = 13056
      w.Send mydata
      respo = w.ResponseText
      Text1 = respo
End Sub

And the last, the server itself :

require_once "lib/nusoap.php";
$debug = 0;
$server = new soap_server();
$server->configureWSDL('terimaxml', 'urn:terimaxml');

function SayHello($xml){
    //messing with xml taking NAME and say Olaa
    echo "Olaaa :D";
}

$server->register('SayHello()',
                    array('xml' =>'xsd:array'),
                   'urn: terimaxml',
                   'urn: terimaxml#__construct()',
                   'rpc',
                   'encoded',
                   '-----'
                );

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

Ive been roaming around the internet for quite sometime to solve this one. so any help would be appreciated, Thanks in advance. :D

Ricky Fauzi
  • 21
  • 1
  • 2

2 Answers2

0

Operation '' is not defined in the WSDL for this service

It's because

$HTTP_RAW_POST_DATA : '';

That operation &apos means you parse the data to xml with apostrophe value that forbidden for xml.

and try to change all apostrophe with double quote(")

$server->register("SayHello()",
                    array("xml" =>"xsd:array"),
                   "urn: terimaxml",
                   "urn: terimaxml#__construct()",
                   "rpc",
                   "encoded",
                   "-----"
                );

correct me if i am wrong.

^^

Josua Marcel C
  • 3,122
  • 6
  • 45
  • 87
0

I am not sure if the code here is deliberately cleaned for readability, but I think I see three problems with it.

First, the function name in the ->register should not include the ().

$server->register("SayHello",
  array("xml" =>"xsd:array"),
  "urn: terimaxml",
  "urn: terimaxml#__construct()",
  "rpc",
  "encoded",
  "-----"
);

Second, I think $HTTP_RAW_POST_DATA is mis-named, and thus you are sending an empty variable to your function.

$HTTP_RAW_POST_DATA = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? 
$GLOBALS["HTTP_RAW_POST_DATA"] : "";

Optional third, HTTP_RAW_POST_DATA is deprecated in favor of the super global array $_POST.

$server->service( http_build_query($_POST) );

I am not certain, I just started working with nusoap two months ago, but those are the differences between my code and yours. Try them one at a time and see if they help.

user123
  • 1,060
  • 3
  • 13
  • 29
DeveloperWeeks
  • 262
  • 2
  • 10