This commit is contained in:
ZweiCD 2020-05-11 10:11:02 +08:00
parent eda883a33b
commit 499f51dc14
2 changed files with 27 additions and 26 deletions

View File

@ -401,14 +401,8 @@ class QimenWms extends BaseWms implements WmsInterface
$query['sign'] = $sign;
$response = $this->post($body, $query);
$content = $response->getBody()->getContents();
$result = XML2Array::createArray($content);
$isSuccess = (empty($result) || !is_array($result) || $result['response']['flag'] != 'success') ? false : true;
$result = [
'success' => $isSuccess,
'response' => $isSuccess ? $result['response'] : $result,
];
return $result;
return $this->getResponse($content);
}
final protected function post($body, $params = [], $headers = ['content-type' => 'text/xml; charset = utf-8'], $ret = []) {
@ -423,6 +417,17 @@ class QimenWms extends BaseWms implements WmsInterface
return $result;
}
function getResponse($content) {
$result = XML2Array::createArray($content);
$isSuccess = (empty($result) || !is_array($result) || $result['response']['flag'] != 'success') ? false : true;
$result = [
'success' => $isSuccess,
'response' => $isSuccess ? $result['response'] : $result,
];
return $result;
}
/**
* 确认回传方法
* @var array

View File

@ -433,16 +433,6 @@ class XinyiWms extends BaseWms implements WmsInterface
return $params;
}
/**
* @发送请求
* @param $body
* @param array $params
* @param array $headers
* @param array $ret
* @return array|\DOMDocument
* @throws \Exception
* @throws \GuzzleHttp\Exception\GuzzleException
*/
final protected function post($body, $params = [], $headers = ['content-type' => 'text/xml; charset = utf-8'], $ret = []) {
$url = $this->config['base_uri'];
$url = $url . http_build_query($params);
@ -453,8 +443,19 @@ class XinyiWms extends BaseWms implements WmsInterface
$client = new Client();
$response = $client->request('POST', $url, $data);
$content = $response->getBody()->getContents();
$ret = XML2Array::createArray($content);
return $ret;
return $content;
}
function getResponse($content) {
$result = XML2Array::createArray($content);
$isSuccess = (empty($result) || !is_array($result) || $result['response']['flag'] != 'success') ? false : true;
$response = [
'success' => $isSuccess,
'response' => $isSuccess ? $result['response'] : $result,
];
return $response;
}
public function xmlPost($method, $params)
@ -462,14 +463,9 @@ class XinyiWms extends BaseWms implements WmsInterface
$xml = Array2XML::createXML('request', $params);
$body = $xml->saveXML();
$res = $this->createSign($method, $body);
$result = $this->post($body, $res);
$content = $this->post($body, $res);
$isSuccess = (empty($result) || !is_array($result) || $result['response']['flag'] != 'success') ? false : true;
$response = [
'success' => $isSuccess,
'response' => $isSuccess ? $result['response'] : $result,
];
return $response;
return $this->getResponse($content);
}
/**