using nusoap returns fault code - php

making a call to a web service method with nusoap returns an error
array(3) { ["faultcode"]=> string(11) "soap:Client" ["faultstring"]=> string(516) "System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: . at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) at System.Web.Services.Protocols.SoapServerProtocol.Initialize() at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)" ["detail"]=> string(0) "" }
is the fault in my calling or with the soap server?
$response = $qes->call('GetXhtml',$url);
var_dump($response);
Above is the call to the function, which accepts 1 parameter ($url) which I have checked as valid.
-------FULL CODE-----
<?php
//include nusoap class
require 'extensions/nusoap/lib/nusoap.php';
//connect to QES
$qes = new nusoap_client("https://www.qes24.com/swindon/ppa/uat/contentserver/contentserver/contentserver.asmx");
$qes->useHTTPPersistentConnection();
$qes->soap_defencoding = 'utf-8';
//check connection
$error = $qes->getError();
//get current page
$curl = curPageURL();//function derives current URL
$furl = $curl."?Type=8AFCCCB9-93DC-421E-A617-92A990EC99A7";
$param = array('url' => $furl);
$response = $qes->call('getXhtml', $param, '','http://tempuri.org/GetXhtml', array('content-type' => 'UTF-8'), true,null,'rpc','literal');
fb::log($response);
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($qes->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($qes->response, ENT_QUOTES) . '</pre>';
//*/
The request SHOULD look like this (according to the company providing the service)
POST /swindon/ppa/uat/ContentServer/ContentServer/ContentServer.asmx HTTP/1.1
Host: www.qes24.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/GetXhtml"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetXhtml xmlns="http://tempuri.org/">
<url> http://localhost/waggleb/?Type=8AFCCCB9-93DC-421E-A617-92A990EC99A7</url>
</GetXhtml>
</soap:Body>
</soap:Envelope>
?>
Actual Full Request made by Nusoap:
POST /swindon/ppa/uat/contentserver/contentserver/contentserver.asmx HTTP/1.1
Host: www.qes24.com
User-Agent: NuSOAP/0.9.5 (1.123)
Connection: close
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/GetXhtml"
Content-Length: 516
<?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/"><SOAP-ENV:Header><content-type xsi:type="xsd:string">UTF-8</content-type></SOAP-ENV:Header><SOAP-ENV:Body><url xsi:type="xsd:string">http://localhost/waggleb/?Type=8AFCCCB9-93DC-421E-A617-92A990EC99A7</url></SOAP-ENV:Body></SOAP-ENV:Envelope>
Full response:
HTTP/1.1 200 OK
Date: Mon, 07 Feb 2011 10:50:25 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 329
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetXhtmlResponse xmlns="http://tempuri.org/"><GetXhtmlResult /></GetXhtmlResponse></soap:Body></soap:Envelope>

From the error that's being returned, I'd guess (but I can't be certain without knowing which API you're trying to use) that the problem is the method name. Perhaps it's cased incorrectly? Either way, this means that the server can't direct your SOAP request to the correct module.

Related

PHP Parse SOAP XML response from SOAP Client

I'm making a SOAP call through php to an external webservice. I finally have it working. The last step is just parsing the response from the SOAP service.
When I do :
echo '{"reference": "'.$client->__getLastResponse().'", "success":"true"}';
I expect to get and I see as the HTML webpage response:
{"reference": "000002R5281191606961", "success":"true"}
However when I look in developer tools source/preview I see this:
{"reference": "<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetPaynetReferenceResponse xmlns="http://www.paynet.com.mx/"><GetPaynetReferenceResult><RespCode>0</RespCode><RespDesc /><PaynetReference>00002R5281191606961</PaynetReference></GetPaynetReferenceResult></GetPaynetReferenceResponse></soap:Body></soap:Envelope>", "success":"true"}
Pretty much the variable I need is in the middle of a ton of XML stuff! How can I just pull out the needed variable, and return it as a json?
In case it helps, here's my code:
$wsdl = 'http://201.147.99.51//PaynetCE/WSPaynetReference.asmx?WSDL';
$trace = true;
$exceptions = false;
$client = new SoapClient($wsdl, array('trace' => $trace, 'exceptions' => $exceptions));
$response = $client->__soapCall("GetPaynetReference", array($data));
echo"<pre>";
print_r($client);
echo"</pre>";
echo"<pre>";
print_r($client->__last_response);
echo"</pre>";
This all seems to work, I get the following output in the html/php page:
SoapClient Object
(
[trace] => 1
[_exceptions] =>
[_soap_version] => 1
[sdl] => Resource id #2
[__last_request] =>
3c090569-1044-48a8-9bc3-de3c8db22a80Recarga tu saldo Elepago.NUMCLIENTE528119160696
[httpsocket] => Resource id #3
[_use_proxy] => 0
[httpurl] => Resource id #4
[__last_request_headers] => POST /PaynetCE/WSPaynetReference.asmx HTTP/1.1
Host: 201.147.99.51
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.4
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.paynet.com.mx/GetPaynetReference"
Content-Length: 626
[__last_response_headers] => HTTP/1.1 200 OK
Date: Wed, 07 May 2014 23:57:45 GMT
Server: Microsoft-IIS/6.0
X-UA-Compatible: IE=EmulateIE7
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 478
[__last_response] => 000002R5281122606961
)
000002R5281122606961
The __last_response is the code I need. I'm trying to send it as a JSON.
When I look at the developer tools at the preview/source of the page I get this:
<pre>SoapClient Object
(
[trace] => 1
[_exceptions] =>
[_soap_version] => 1
[sdl] => Resource id #2
[__last_request] => <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.paynet.com.mx/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SOAP-ENV:Body><ns1:GetPaynetReference><ns1:issuerCod>3c090569-1044-48a8-9bc3-de3c8db22a80</ns1:issuerCod><ns1:description>Recarga tu saldo Elepago.</ns1:description><ns1:params><ns1:Parameter><ns1:Name>NUMCLIENTE</ns1:Name><ns1:Value xsi:type="xsd:string">528119160696</ns1:Value></ns1:Parameter></ns1:params></ns1:GetPaynetReference></SOAP-ENV:Body></SOAP-ENV:Envelope>
[httpsocket] => Resource id #3
[_use_proxy] => 0
[httpurl] => Resource id #4
[__last_request_headers] => POST /PaynetCE/WSPaynetReference.asmx HTTP/1.1
Host: 201.147.99.51
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.4
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://www.paynet.com.mx/GetPaynetReference"
Content-Length: 626
[__last_response_headers] => HTTP/1.1 200 OK
Date: Wed, 07 May 2014 23:57:45 GMT
Server: Microsoft-IIS/6.0
X-UA-Compatible: IE=EmulateIE7
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 478
[__last_response] => <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetPaynetReferenceResponse xmlns="http://www.paynet.com.mx/"><GetPaynetReferenceResult><RespCode>0</RespCode><RespDesc /><PaynetReference>00002R5281191606961</PaynetReference></GetPaynetReferenceResult></GetPaynetReferenceResponse></soap:Body></soap:Envelope>
)
</pre><pre><?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetPaynetReferenceResponse xmlns="http://www.paynet.com.mx/"><GetPaynetReferenceResult><RespCode>0</RespCode><RespDesc /><PaynetReference>00002R5281191606961</PaynetReference></GetPaynetReferenceResult></GetPaynetReferenceResponse></soap:Body></soap:Envelope></pre>
Use the SimpleXMLElement::xpath method with the following path...
/soap:Envelope/soap:Body/a:GetPaynetReferenceResponse/a:GetPaynetReferenceResult/a:PaynetReference/text()
after registering the following namespace prefixes with SimpleXMLElement::registerXPathNamespace:
Prefix Namespace
------ ---------
xsi http://www.w3.org/2001/XMLSchema-instance
xsd http://www.w3.org/2001/XMLSchema
soap http://schemas.xmlsoap.org/soap/envelope/
xml http://www.w3.org/XML/1998/namespace
a http://www.paynet.com.mx/
Taking this approach, transform...
echo '{"reference": "'.$client->__getLastResponse().'", "success":"true"}';
...as follows:
$xml = new SimpleXMLElement($client->__getLastResponse());
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->registerXPathNamespace('xsd', 'http://www.w3.org/2001/XMLSchema');
$xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('xml', 'http://www.w3.org/XML/1998/namespace');
$xml->registerXPathNamespace('a', 'http://www.paynet.com.mx/');
$xpath = '/soap:Envelope/soap:Body/a:GetPaynetReferenceResponse/a:GetPaynetReferenceResult/a:PaynetReference/text()';
$result = $xml->xpath($xpath);
if ($result != FALSE && count($result) > 0) {
echo '{"reference": "' . $result[0] . '", "success":"true"}';
} else {
// TODO: Whatever....
}
EDIT:
To be perfectly clear about exactly how I checked this solution, here is the PoC I sketched without being able to use $client->__getLastResponse() per se:
<html>
<head><title>PoC Page</title></head>
<body>
<?php
// FORNOW - Use $lastResponse since I can't really use $client->__getLastResponse() for a PoC.
$lastResponse = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetPaynetReferenceResponse xmlns="http://www.paynet.com.mx/"><GetPaynetReferenceResult><RespCode>0</RespCode><RespDesc /><PaynetReference>00002R5281191606961</PaynetReference></GetPaynetReferenceResult></GetPaynetReferenceResponse></soap:Body></soap:Envelope>';
$xml = new SimpleXMLElement($lastResponse);
//$xml = new SimpleXMLElement($client->__getLastResponse());
$xml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$xml->registerXPathNamespace('xsd', 'http://www.w3.org/2001/XMLSchema');
$xml->registerXPathNamespace('soap', 'http://schemas.xmlsoap.org/soap/envelope/');
$xml->registerXPathNamespace('xml', 'http://www.w3.org/XML/1998/namespace');
$xml->registerXPathNamespace('a', 'http://www.paynet.com.mx/');
$xpath = '/soap:Envelope/soap:Body/a:GetPaynetReferenceResponse/a:GetPaynetReferenceResult/a:PaynetReference/text()';
$result = $xml->xpath($xpath);
if ($result != FALSE && count($result) > 0) {
echo '{"reference": "' . $result[0] . '", "success":"true"}';
} else {
// TODO: Whatever....
}
?>
</body>
</html>
Thanks J0e3gan for the answer! Worked perfect. I also found that this alternative works well. Basically create a new DOM, and just grab whats inside the tags.
$doc = new DOMDocument('1.0', 'utf-8');
$doc->loadXML( $soapResponse );
$XMLresults = $doc->getElementsByTagName("SearchFlightAvailability33Response");
$output = $XMLresults->item(0)->nodeValue;
Courtesy of:
How to convert SOAP response to PHP Array?

PHP soap response return with NaN

i'm sorry if the title might misleading, i'm kinda dumb but could you give me a little hint for me.
i'm trying for bmi web service
soap request
POST /webservices/bmiservice.asmx HTTP/1.1
Host: www.beetledev.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.beetledev.com/getBmiValue"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getBmiValue xmlns="http://www.beetledev.com">
<w>double</w>
<h>double</h>
</getBmiValue>
</soap:Body>
</soap:Envelope>
soap response
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getBmiValueResponse xmlns="http://www.beetledev.com">
<getBmiValueResult>double</getBmiValueResult>
</getBmiValueResponse>
</soap:Body>
</soap:Envelope>
PHP coding
<?php
require_once "lib/nusoap.php";
$client = new nusoap_client("http://www.beetledev.com/webservices/bmiservice.asmx");
$error = $client->getError();
if ($error) {
echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
}
$result = $client->call('getBmiValue',array('w' => 62, 'h' =>167),null, 'http://www.beetledev.com/getBmiValue');
if ($client->fault) {
echo "<h2>Fault</h2><pre>";
print_r($result);
echo "</pre>";
}
else {
$error = $client->getError();
if ($error) {
echo "<h2>Error</h2><pre>" . $error . "</pre>";
}
else {
echo "<h2>BMI</h2><pre>";
echo $result;
echo "</pre>";
}
}
echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
?>
result
BMI
NaN
Request
POST /webservices/bmiservice.asmx HTTP/1.0
Host: www.beetledev.com
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.beetledev.com/getBmiValue"
Content-Length: 476
<?xml version="1.0" encoding="UTF-8"?><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><getBmiValue><w xsi:type="xsd:int">62</w><h xsi:type="xsd:int">167</h></getBmiValue></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/8.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Sun, 27 Apr 2014 14:26:40 GMT
Connection: close
Content-Length: 364
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><getBmiValueResponse xmlns="http://www.beetledev.com"><getBmiValueResult>NaN</getBmiValueResult></getBmiValueResponse></soap:Body></soap:Envelope>
i dont know where i do wrong, i'm hoping for a little hint
Thank you
i found the solution to my problem
first
$client = new nusoap_client("http://www.beetledev.com/webservices/bmiservice.asmx");
change to
$client = new nusoap_client('http://www.beetledev.com/webservices/bmiservice.asmx?WSDL',TRUE);
second
$result = $client->call('getBmiValue',array('w' => 62, 'h' =>167),null, 'http://www.beetledev.com/getBmiValue');
change to
$result = $client->call('getBmiValue',array('w' => 62,'h' => 167));
third
the thing is because there are two variable? (not sure with term), so it was kept in an array
please dont mind the variable name
$fConversionRate = (float) $result['getBmiValueResult'];
and done and i get my bmi result.

Transport level information does not match with SOAP Message namespace URI in PHP nusoap

I'm getting following error response while I subscribe to service. Transport level information does not match with SOAP Message namespace URI
Response :
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
X-UA-Compatible: IE=EmulateIE7
Set-Cookie: JSESSIONID=ED9D677679699927EC1C9CBACE00B7BA.server2; Path=/
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Fri, 25 Oct 2013 07:17:58 GMT
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/none</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>urn:uuid:C8F752B9E879AE5333138268547859511312499</wsa:MessageID>
<wsa:Action>http://www.w3.org/2005/08/addressing/soap/fault</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<soapenv:Fault>
<faultcode/>
<faultstring>Transport level information does not match with SOAP Message namespace URI</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Here is my php code. I have used nusoap
require_once('lib/nusoap.php');
// Load SOAP URL
$client = new nusoap_client('http://192.168.1.34:1212/services/MYInterfaceTestingMgrService?wsdl','wsdl');
$client->soap_defencoding = 'utf-8';
$client->useHTTPPersistentConnection(); // Uses http 1.1 instead of 1.0
$soapaction = 'RemoveAppendantProduct'; // Load SOAP Action
// soap message
$request_xml = <<<SOAPXML
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:bus="http://www.xyz.com/bme/cbsinterface/cbs/businessmgrmsg"
xmlns:com="http://www.xyz.com/bme/cbsinterface/common"
xmlns:bus1="http://www.xyz.com/bme/cbsinterface/cbs/businessmgr">
<soap:Header/>
<soap:Body>
<bus:RemoveAppendantProductRequestMsg>
<RequestHeader>
<com:CommandId>RemoveAppendantProduct</com:CommandId>
<com:Version>xx</com:Version>
<com:TransactionId/>
<com:SequenceId>xx</com:SequenceId>
<com:RequestType>Event</com:RequestType>
<com:SessionEntity>
<com:Name>$xyz_Name</com:Name>
<com:Password>$xyz_Password</com:Password>
<com:RemoteAddress/>
</com:SessionEntity>
<com:SerialNo>$xyz_ser_no</com:SerialNo>
</RequestHeader>
<RemoveAppendantProductRequest>
<bus1:SubscriberNo>$xyzr_sub_id</bus1:SubscriberNo>
<bus1:Product>
<bus1:ProductID>$xyz_id</bus1:ProductID>
<bus1:ValidMode>123456</bus1:ValidMode>
<bus1:ExpireDate>$xyz_eff_date</bus1:ExpireDate>
</bus1:Product>
</RemoveAppendantProductRequest>
</bus:RemoveAppendantProductRequestMsg>
</soap:Body>
</soap:Envelope>
SOAPXML;
$err = $client->getError();
if ($err) {
echo 'Constructor error' . $err;
}
$result = $client->send($request_xml, $soapaction, ''); // passing soap message via soap php client
Pls let me know how to resolve this issue.

send xml using nusoap

my soap requestformat should look like this
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>< WsAbcMobileAcctInq xmlns="http://tempuri.org/"><xml_var><HCMSG xmlns="">
<ABC><ABCTRANSID>MOBL</ABCTRANSID></ABC><REF><TXNTYPE>INQ</TXNTYPE><SC_CD>000ACD</SC_CD>
< REFNO>MOBL0000000060018987941MAT</REFNO></REF><FIXPART><TXNDATE>20110105</TXNDATE>
<TXNTIME>11464178</TXNTIME><AGN_CD>000000006001</ AGN_CD ></FIXPART><VARPART>
<AC_NO TYP="N">0000000000008946565</AC_NO>
<IC_NO TYP="N">0008956466546</ IC_NO>
<ID_CD TYP="S">IN</ ID_CD>
</VARPART></HCMSG></xml_var></ WsAbcMobileAcctInq></soap:Body></soap:Envelope>
but the problem is i don't know how to put it using nusoap. here's what i've been doing:
require_once('lib/nusoap.php');
$client = new nusoap_client('http://domain.my/MobileData/Service.asmx', false);
$params = '<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>< WsAbcMobileAcctInq xmlns="http://tempuri.org/"><xml_var><HCMSG xmlns="">
<ABC><ABCTRANSID>MOBL</ABCTRANSID></ABC><REF><TXNTYPE>INQ</TXNTYPE><SC_CD>000ACD</SC_CD>
< REFNO>MOBL0000000060018987941MAT</REFNO></REF><FIXPART><TXNDATE>20110105</TXNDATE>
<TXNTIME>11464178</TXNTIME><AGN_CD>000000006001</ AGN_CD ></FIXPART><VARPART>
<AC_NO TYP="N">0000000000008946565</AC_NO>
<IC_NO TYP="N">0008956466546</ IC_NO>
<ID_CD TYP="S">IN</ ID_CD>
</VARPART></HCMSG></xml_var></ WsAbcMobileAcctInq></soap:Body></soap:Envelope>';
$answer = $client->call('WsAbcMobileAcctInq', array('WsAbcMobile' => $params), '', 'http://tempuri.org/WsAbcMobileAcctInq');
$error = $client->getError();
if ($error){
print_r($client->response);
print_r($client->getDebug());
print_r($client->getError());
die();
}
and basically i got this error:
HTTP/1.1 500 Internal Server Error Connection: close Date: Thu, 24 Nov 2011 05:47:47 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/xml; charset=utf-8 Content-Length: 441 soap:ServerServer was unable to process request. ---> Object reference not set to an instance of an object
any clue?

HTTP Request with PHP + NuSoap

I'm trying to create a http request to our web service, my test XML works when directly inputted into the webservices test input field and I click "Invoke", but when trying to use the same data with PHP + NuSoap, I get a peculiar error which I've been unable to solve, I've tried to google for it but nothing relevant shows up for this case.
Here is the Request:
POST /iInterface_pc2/service.asmx HTTP/1.0
Host: 10.10.86.55
User-Agent: NuSOAP/0.9.6dev (1.137)
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.xxxx.com.cn/TransferMaterialInfo"
Content-Length: 722
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TransferMaterialInfo xmlns="http://www.xxxx.com.cn/">
<Materiallist>
<Materialinfo>
<id>123456</id>
<title>Hello word</title>
<datetime>2011-04-23 12:12:12</datetime>
<contributor>Some One</contributor>
<materialurl>www.website.com/path/audio1.mp3</materialurl>
<duration>10000</duration>
<status>0</status>
<remark></remark>
</Materialinfo>
</Materiallist>
</TransferMaterialInfo>
</soap:Body>
</soap:Envelope>
And the Response:
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Thu, 28 Apr 2011 11:04:11 GMT
Connection: close
Content-Length: 428
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Server was unable to process request. ---> Value cannot be null.
Parameter name: s</faultstring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
And finally the PHP I use to generate the request
<?php
// include soap file
require_once('lib/nusoap.php');
// set end point
$endpoint = "http://10.10.86.55/iInterface_pc2/service.asmx";
// create client
$client = new nusoap_client($endpoint);
if ( $client->getError() ) {
print "Soap Constructor Error: ";
print_r($client->getError());
}
// Human readable
$request = <<<HEREDOC
<TransferMaterialInfo xmlns="http://www.xxxx.com.cn/">
<Materiallist>
<Materialinfo>
<id>123456</id>
<title>Hello word</title>
<datetime>2011-04-23 12:12:12</datetime>
<contributor>Some One</contributor>
<materialurl>www.website.com/path/audio1.mp3</materialurl>
<duration>10000</duration>
<status>0</status>
<remark></remark>
</Materialinfo>
</Materiallist>
</TransferMaterialInfo>
HEREDOC;
$action = "http://www.xxxx.com.cn/TransferMaterialInfo";
$msg = $client->serializeEnvelope($request, '', array(), 'document', 'encoded', '');
$result = $client->send($msg, $action);
if ( $client->fault ) { //soap_fault
print "Soap Fault :";
print_r($client->fault->faultcode);
print_r($client->fault->faultstring);
}
elseif ( $client->getError() ) {
print "Soap Error :";
print_r($client->getError());
}
else {
print "Result: ";
print_r($result);
}
..print stuff
?>
Any insights and guesses GREATLY appreciated. I've been banging my head against a brick wall for a good while now. :/
I believe the server is seeing the < and > characters and decoding it to >
You may need to urlencode the data before sending
i am not sure , if that will help you or not , but check it any way
http://mohammed-magdy.blogspot.com/2011/04/creating-web-services-using-php.html
The problem has been solved and was actually caused by faulty ASP code expecting only whitespaces to be html-encoded, resulting in faulty response.

Categories