带有NaN的PHP soap响应返回
很抱歉,如果标题有误导性,我有点傻,但你能给我一点提示吗 我正在尝试bmi web服务 soap请求带有NaN的PHP soap响应返回,php,soap,Php,Soap,很抱歉,如果标题有误导性,我有点傻,但你能给我一点提示吗 我正在尝试bmi web服务 soap请求 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"
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>
POST/webservices/bmiservice.asmx HTTP/1.1
主持人:www.beetledev.com
内容类型:text/xml;字符集=utf-8
内容长度:长度
SOAPAction:“http://www.beetledev.com/getBmiValue"
双重的
双重的
soap响应
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>
HTTP/1.1200正常
内容类型:text/xml;字符集=utf-8
内容长度:长度
双重的
PHP编码
<?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>";
?>
结果
BMI
楠
要求
POST/webservices/bmiservice.asmx HTTP/1.0
主持人:www.beetledev.com
用户代理:NuSOAP/0.9.5(1.123)
内容类型:text/xml;字符集=UTF-8
SOAPAction:“http://www.beetledev.com/getBmiValue"
内容长度:476
62167
回答
HTTP/1.1200ok
缓存控制:专用,最大年龄=0
内容类型:text/xml;字符集=utf-8
服务器:Microsoft IIS/8.5
X-AspNet-Version:2.0.50727
X-Powered-By:ASP.NET
日期:2014年4月27日星期日14:26:40 GMT
连接:关闭
内容长度:364
楠
我不知道我哪里做错了,我希望得到一点提示
谢谢我找到了解决问题的办法 首先 改为 第二 改为 第三 问题是因为有两个变量?(对术语不确定),所以它被保存在一个数组中 请不要介意变量名 完成后,我得到了我的体重指数结果
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>
$client = new nusoap_client("http://www.beetledev.com/webservices/bmiservice.asmx");
$client = new nusoap_client('http://www.beetledev.com/webservices/bmiservice.asmx?WSDL',TRUE);
$result = $client->call('getBmiValue',array('w' => 62, 'h' =>167),null, 'http://www.beetledev.com/getBmiValue');
$result = $client->call('getBmiValue',array('w' => 62,'h' => 167));
$fConversionRate = (float) $result['getBmiValueResult'];