我试图弄清楚如何在我的Laravel中使用Laminas SOAP生成多级WSDL。我也读了文档和chatgpt。但我仍然困惑如何设置,这里的链接:https://docs.laminas.dev/laminas-soap/auto-discovery/
这是我的控制器代码:
public function soap()
{
$server = new Server(
route('soap-wsdl'),
[
'actor' => route('soap-server'),
]
);
$this->populateServer($server);
$server->setReturnResponse(true);
$response = response($server->handle());
$response->header('Content-Type', 'text/xml');
return $response;
}
public function wsdl(Request $request)
{
$wsdl = new AutoDiscover();
$this->populateServer($wsdl);
$wsdl->setUri(route('soap-server'))
->setServiceName('InaportWSDL');
return response()->make($wsdl->toXml())
->header('Content-Type', 'application/xml');
}
private function populateServer($server)
{
// Expose a class and its methods:
$server->setClass(ResponseServices::class);
}
这是我的ResponseServices类(或Controller):
class ResponseServices {
/**
* @param string $user
* @param string $password
* @param array $detail
*/
public function entryRpkro($user, $password, $detail)
{
}
}
使用wizdler的结果:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<entryRpkro xmlns="http://localhost:8000/soap">
<user>[string]</user>
<password>[string]</password>
<detail>[Array]</detail>
</entryRpkro>
</Body>
</Envelope>
所以我想把这个wsdl改成这样:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<entryRpkro xmlns="http://localhost:8000/soap">
<user>[string]</user>
<password>[string]</password>
<detail>
<name>[string]</name>
<age>[int]</age>
</detail>
</entryRpkro>
</Body>
</Envelope>
1条答案
按热度按时间qlfbtfca1#
试试这样的方法:创建另一个文件
Details.php
。不要忘记设置命名空间。把上面的代码改成这样:
请记住,您始终需要在
@param
和@return
注解中使用FQCN,以便获得与薄层的正确Map。也许将来你也想调整laminas的complexTypeStrategy。到目前为止,ArrayOfTypeComplex
对我来说一直是最好的。