Closed wa05 closed 5 years ago
Hi. Thanks for an issue.
I do not known how to help you. What kind of problem do you have?
When you use the register function the first parameter is a string, that string is the method that you will implement, how you can point that string to a method from the same controller that were you are instanciating the web server ...
Now I'm using a helpers file but I'm trying to make it more "elegantly"..
Well, I've found this thread https://stackoverflow.com/a/8094692.
// register the class method and the params of the method
$server->register("myClass.ShowString"
,array('name'=>'xsd:string')
,array('return'=>'xsd:string')
,$namespace,false
,'rpc'
,'encoded'
,'Sample of embedded classes...'
);
Finally I solved adding a global helper file to the composer.json and Laravel encounters the method in that file
Hi wa05, you have some example of your solution? please i have exactly the same problem right now u.u,
Route::any('ws-delos', 'WebService\WsController@connect');
public function connect() { try {
$server = new \nusoap_server();
$server->configureWSDL('WMS', "urn:delos", url('ws-delos'), 'rpc');
$this->server = $server;
$this->server->wsdl->addComplexType(
'item',
'complexType',
'struct',
'all',
'',
[
'codigoMaterial' => [
'name' => 'codigoMaterial', 'type' => 'xsd:string'
],
'cantidad' => [
'name' => 'cantidad', 'type' => 'xsd:int'
],
'nroTransaccion' => [
'name' => 'nroTransaccion', 'type' => 'xsd:int'
],
'codigoInterno' => [
'name' => 'codigoInterno', 'type' => 'xsd:int'
]
]
);
$this->server->register('DocumentoEgreso_Agregar',
[
'empresa' => 'xsd:int',
'nroPedido' => 'xsd:string',
'cliente' => 'xsd:string',
'codigoTransportista' => 'xsd:int',
'descripcionTransportista' => 'xsd:string',
'items' => 'tns:listaEgreso'
],
[
'output' => 'xsd:string'
],
"urn:delos",
"urn:delos#DocumentoEgreso_Agregar",
"rpc",
'encoded',
"Circuito Comercial - Recibe la tarea y la graba en estado pendiente");
} catch (Exception $e) {
return response('ERROR ' . $e->getMessage());
}
$rawPostData = file_get_contents("php://input");
return response($this->server->service($rawPostData), 200)
->header('Content-Type', 'text/xml')
->header('charset', 'ISO-8859-1');
}
composer.json
`
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"files": [
"app/helper.php"
],
`
composer.json
"autoload": { "classmap": [ "database/seeds", "database/factories" ], "files": [ "app/helper.php" ],
web.php
Route::any('ws-delos', 'WebService\WsController@connect');
controller ` public function connect() { try {
$server = new \nusoap_server();
$server->configureWSDL('WMS', "urn:delos", url('ws-delos'), 'rpc');
$this->server = $server;
$this->server->wsdl->addComplexType(
'item',
'complexType',
'struct',
'all',
'',
[
'codigoMaterial' => [
'name' => 'codigoMaterial', 'type' => 'xsd:string'
],
'cantidad' => [
'name' => 'cantidad', 'type' => 'xsd:int'
],
'nroTransaccion' => [
'name' => 'nroTransaccion', 'type' => 'xsd:int'
],
'codigoInterno' => [
'name' => 'codigoInterno', 'type' => 'xsd:int'
]
]
);
$this->server->register('DocumentoEgreso_Agregar',
[
'empresa' => 'xsd:int',
'nroPedido' => 'xsd:string',
'cliente' => 'xsd:string',
'codigoTransportista' => 'xsd:int',
'descripcionTransportista' => 'xsd:string',
'items' => 'tns:listaEgreso'
],
[
'output' => 'xsd:string'
],
"urn:delos",
"urn:delos#DocumentoEgreso_Agregar",
"rpc",
'encoded',
"Circuito Comercial - Recibe la tarea y la graba en estado pendiente");
} catch (Exception $e) {
return response('ERROR ' . $e->getMessage());
}
$rawPostData = file_get_contents("php://input");
return response($this->server->service($rawPostData), 200)
->header('Content-Type', 'text/xml')
->header('charset', 'ISO-8859-1');
}`
helper.php `function DocumentoEgreso_Agregar($empresa, $nroPedido, $cliente, $codigoTransportista, $descripcionTransportista, $items, $codigoLugarEnvio = null) { $controller = app('app\Http\Controllers\WebService\WsController');
return $controller->wsEgresoData($empresa, $nroPedido, $cliente,
$codigoTransportista, $descripcionTransportista, $items, $codigoLugarEnvio);
} `
thank you so much wa05 you save my ass, a great contribution
thanks you @wa05 !
Hi, would like to know on how did you define the code below on the register function. Thanks
'items' => 'tns:listaEgreso'
->> listaEgreso class where did you define it? inside the controller?
@excalibur1028 excuse me for the slow response... Its defined in the controller... as a complexType
$this->server->wsdl->addComplexType( 'listaEgreso', 'complexType', 'array', '', 'SOAP-ENC:Array', [], [ [ 'ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:item[]' ] ], 'tns:item' );
Is there a way to place test inside the controller??