我已经建立了一个使用PHP wsdl soap服务器的Java客户端服务器并且它成功地进行了通信,但是我无法获得响应(响应值为空)。当我试图检查请求和响应时,它肯定会回应一些东西。我的java代码或服务器有问题吗?
这是我的客户端java代码:
package siclient;
import wsdlquery.*;
public class SIClient {
public static void main(String[] args) {
WsdlQueryRequest request = new WsdlQueryRequest();
request.setToken("ABCDEFGHIJ");
ArryQueryRequest array = new ArryQueryRequest();
array.setParam1("W1113OK");
array.setParam2("20151001");
array.setParam3("20151001");
request.getAddItemsRequest().add(array);
WsdlQueryResponse respond = send(request);
System.out.println("Result : " + respond);
}
private static WsdlQueryResponse send(WsdlQueryRequest wsdlQueryRequest) {
WsdlQuery service = new WsdlQuery();
WsdlQueryPortType port = service.getWsdlQueryPort();
return port.gps(wsdlQueryRequest);
}
这是结果
Result : null
这是我运行时获得的请求和响应
---[HTTP request - https://website.com:443/xxxxx.php]---
Accept: [text/xml, multipart/related]
Content-Type: [text/xml; charset=utf-8]
SOAPAction: ["urn:wsdlQuery#gps"]
User-Agent: [JAX-WS RI 2.2.4-b01]
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:gps xmlns:ns2="urn:wsdlQuery"><wsdlQueryRequest><token>7H1S3FY7U2</token><addItemsRequest><param1>H4444HH</param1><param2>20151001</param2><param3>20151027</param3></addItemsRequest></wsdlQueryRequest></ns2:gps></S:Body></S:Envelope>--------------------
---[HTTP response - https://website.com:443/xxxxx.php - 200]---
null: [HTTP/1.1 200 OK]
Connection: [Keep-Alive]
Content-Length: [539]
Content-Type: [text/xml; charset=UTF-8]
Date: [Sun, 06 Mar 2016 11:53:21 GMT]
Keep-Alive: [timeout=5, max=100]
Server: [Apache/2.2.11 (Unix) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/5.2.9 mod_apreq2-20051231/2.6.0 mod_perl/2.0.4 Perl/v5.10.0]
X-Powered-By: [PHP/5.2.9]
X-SOAP-Server: [NuSOAP/0.9.5 (1.123)]
<?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:Body><gpsResponse xmlns="urn:wsdlQuery"><wsdlQueryResponse><ResponseCode>01</ResponseCode><ResponseMessage>Response value was here</ResponseMessage></wsdlQueryResponse></gpsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>--------------------
然后我尝试使用php和代码
来设置客户端<?php
require_once('lib/nusoap.php');
$token='7H1S3FY7U2';
$wsdl='https://website.com/xxxxx.php?wsdl';
$client = new nusoap_client($wsdl,true);
$err = $client->getError();
if ($err){
echo '<h2>Constructor Error</h2><pre>' . $err . '</pre>';
}else{
$param['wsdlQueryRequest'] = array('token'=>$token,
'addItemRequest'=>array(
array(
'param1'=>'W1113OK',
'param2'=>'20150101',
'param3'=>'20151001'
),
)
);
$result = $client->call('gps', $param);
print_r($result);
}
?>
php代码的结果是这样的
Array ( [ResponseCode] => 01 [ResponseMessage] => Response value was here )