我正在基于wsdl创建一个肥皂服务器。 通过wsdl在服务器上创建方法Execute,该方法接受带参数的请求。参数具有类型(“ Cat_goods”,“ Doc_price”等)。根据这些类型,我需要在服务器上执行不同的操作。 但是,当我从SoapUI发送信封时,在服务器上我得到一个未指定参数类型的对象。 在处理带有不同类型参数的请求时,如何确定应在服务器上调用哪些方法。 单个产品请求的示例:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:exc="http://www.mysite.ru/schema/1.0/erp/exch-store">
<soapenv:Header/>
<soapenv:Body>
<exc:Execute>
<exc:Request xmlns="http://www.mysite.ru/schema/1.0/erp/exch-store" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChangeReq">
<sysID>b66056fg-77hv-kj7v-0f8r-9fkbkf85mmks</sysID>
<Objects>
<Object xsi:type="Cat_goods">
<Reference>
<ID_SCM>a034lksdjfsd-23423</ID_SCM>
<Name>Good name</Name>
</Reference>
<Code>AA-212</Code>
<Article>AA-0212</Article>
<Weight>0</Weight>
<Description/>
<DivisionValue>0</DivisionValue>
<AdvancedProps/>
</Object>
</Objects>
</exc:Request>
</exc:Execute>
</soapenv:Body>
</soapenv:Envelope>
服务器返回:
object(stdClass)#2 (1) {
["Request"]=>object(stdClass)#3 (2) {
["sysID"]=>string(36) "b66056fg-77hv-kj7v-0f8r-9fkbkf85mmks"
["Objects"]=>object(stdClass)#4 (1) {
["Object"]=>object(stdClass)#5 (7) {
["Reference"]=>object(stdClass)#6 (1) {
["Name"]=>string(9) "Good name"
}
["Code"]=>string(6) "AA-212"
["Article"]=>string(7) "AA-0212"
["Weight"]=>string(1) "0"
["Description"]=>string(0) ""
["DivisionValue"]=>string(1) "0"
["AdvancedProps"]=>object(stdClass)#7 (0) {
}
}
}
}
}
样品价格更新请求:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:exc="http://www.mysite.ru/schema/1.0/erp/exch-store">
<soapenv:Header/>
<soapenv:Body>
<exc:Execute>
<exc:Request xmlns="http://www.mysite.ru/schema/1.0/erp/exch-store" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ChangeReq">
<sysID>b66056fg-77hv-kj7v-0f8r-9fkbkf85mmks</sysID>
<Objects>
<Object xsi:type="Doc_price">
<Reference>
<ID_SCM>a034lksdjfsd-23423</ID_SCM>
<Number>AA-00000001</Number>
<Date>2018-10-01</Date>
</Reference>
<Items>
<Item>
<Goods>
<ID_SCM>12345</ID_ERP>
<Name>Good name</Name>
</Goods>
<Price>160</Price>
<Currency>RUB</Currency>
<TypeOfPrice>
<ID_SCM>54321</ID_ERP>
<Name>Price name</Name>
</TypeOfPrice>
</Item>
<Item>
<Goods>
<ID_SCM>12346</ID_ERP>
<Name>Good name</Name>
</Goods>
<Price>320</Price>
<Currency>RUB</Currency>
<TypeOfPrice>
<ID_SCM>64321</ID_ERP>
<Name>Price name</Name>
</TypeOfPrice>
</Item>
</Items>
</Object>
</Objects>
</exc:Request>
</exc:Execute>
</soapenv:Body>
</soapenv:Envelope>
服务器返回:
object(stdClass)#2 (1) {
["Request"]=>object(stdClass)#3 (2) {
["sysID"]=>string(36) "b66056fg-77hv-kj7v-0f8r-9fkbkf85mmks"
["Objects"]=>object(stdClass)#4 (1) {
["Object"]=>object(stdClass)#5 (2) {
["Reference"]=>object(stdClass)#6 (3) {
["ID_SCM"]=>string(18) "a034lksdjfsd-23423"
["Number"]=>string(11) "AA-00000001"
["Date"]=>string(10) "2018-10-01"
}
["Items"]=>object(stdClass)#7 (1) {
["Item"]=>array(2) {
[0]=>object(stdClass)#8 (4) {
["Goods"]=>object(stdClass)#9 (2) {
["ID_SCM"]=>string(5) "12345"
["Name"]=>string(9) "Good name"
}
["Price"]=>string(3) "160"
["Currency"]=>string(3) "BYN"
["TypeOfPrice"]=>object(stdClass)#10 (2) {
["ID_SCM"]=>string(5) "54321"
["Name"]=>string(9) "Price name"
}
}
[1]=>object(stdClass)#11 (4) {
["Goods"]=>object(stdClass)#12 (2) {
["ID_SCM"]=>string(5) "12346"
["Name"]=>string(9) "Good name"
}
["Price"]=>string(3) "320"
["Currency"]=>string(3) "BYN"
["TypeOfPrice"]=>object(stdClass)#13 (2) {
["ID_SCM"]=>string(5) "64321"
["Name"]=>string(9) "Price name"
}
}
}
}
}
}
}
}
服务器代码:
<?php
header("Content-Type: text/html; charset=utf-8");
header('Cache-Control: no-store, no-cache');
ini_set("soap.wsdl_cache_enabled", "0");
class ExchServ {
public function Execute($paramData) {
var_dump($paramData);die();
}
}
$server = new SoapServer('http://www.mysite.ru/exch/serv.wsdl',
array(
'cache_wsdl' => WSDL_CACHE_NONE
,'trace' => true
)
);
$server->setClass("ExchServ");
$server->handle();