0

I've been spending sometime with problem. I have a endpoint I want to send some data and receive a response.

I've look online and I've seen that Zend\Soap\Server is used to build methods, and Zend\Soap\Client can than use those methods. I would like for someone to explain what to write in those methods, and how that helps with getting a response.

$client = new Client($this->wsdl, array('soap_version' => SOAP_1_1));

Now we can $client->SOMEMETHOD();

My questions are: 'Where do I get this method from?', 'what will method do?', and 'how do I use it?'

  • please , indicate which version of zend you are using. 1 ? 2.x ? 3.x ? – Eric Oct 18 '19 at 01:27
  • here is a documentation for zend 2 : Soap :server side https://framework.zend.com/manual/2.0/en/modules/zend.soap.server.html or Soap Client Side : https://framework.zend.com/manual/2.0/en/modules/zend.soap.client.html – Eric Oct 18 '19 at 01:35
  • I need Soap client side just to use the endpoint. But I don't know what to write at the parameters of the function. – Gerald Ibra Oct 18 '19 at 07:47
  • Right now I have this: – Gerald Ibra Oct 18 '19 at 07:47
  • $client = new Client($this->wsdl, array( 'soap_version' => SOAP_1_1 ) ); $params = [ '_PRCODFISCALE' => 'BRSLSN312213TY' '_PRTIPOOPERAWS' => 'REPFAM' ]; $client->ws_fam_sgf($params); $result = $client->getLastResponse(); die($result); – Gerald Ibra Oct 18 '19 at 07:53
  • I posted a response "SOAP short base". But I think you should deepen your knowledge about SOAP (the principle is not very complicated) and read the WDSL file (in xml) to know the routes / messages, the parameters to send for each route, and what will you have returned. all this is described in the WDSL – Eric Oct 18 '19 at 08:30

2 Answers2

0

SOAP short base

SOAP allows to request an online service. (use as a client code) for example you can query AMAZON on a product, know its price, etc.

SOAP works in 2 different ways:

way 1: wdsl mode

when you create a connection to a SOAP client, you must provide a link that will provide an XML file: the wdsl

example: type in your browser: http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl

congratulation : you see (discover) the way to query AMAZON !

this XML file tells you what you can ask for: a price, a product info, a search, etc ..: these are the routes.

for each route (each possible query) the parameters you must provide, the validity check of these parameters: example: route = search article, param1 = article name, type of parameter = string, etc...

$client = new Client($this->wsdl, array( 'soap_version' => SOAP_1_1 ) )

create a client object :
$this->wsdl a link to xml file (the discovery part)
it's a URI string : example : "http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl"

array( 'soap_version' => SOAP_1_1 ) = i use SOAP version xx, you can add more options in this array.

way 2: non wdsl mode

you do not provide a wsdl link or file... but you must know how to handle request and responses

deep learning

search on google a tutorial for SOAP, there are online requester for test purpose, etc... then use it in zend

Eric
  • 608
  • 4
  • 11
0

I solved my problem, so I'll post it here for anyone to understand.

$client = new Client($wsdl, ['soap_version' => SOAP_1_1]);

$params = [
   'args0' =>  [ 
      '_PRCODASSOC' => null, 
      '_PRCODDELEG' => null, 
      '_PRCODFISCALE' => 'BRSLSN312213TY', 
      '_PRCODFSDDIRI' => null,
      '_PRTIPOOPERAWS' => 'REPFAM' 
    ]
];

$client->ws_fam_sgf($params); 
$result = $client->getLastResponse(); 
die($result); 

All I did was add 'args' => [] and added all my parameters inside that key.