BackEnd create route generate WSDL file using zend soap of Zendframework in laravel 7
if(isset($_GET['wsdl'])) {
// Create wsdl object and register type(s).
$wsdl = new Wsdl('wsdl', $this->endpoint);
foreach($this->types as $key => $class) {
$wsdl->addType($class, $key);
}
// Set type(s) on strategy object.
$this->strategy->setContext($wsdl);
foreach($this->types as $key => $class) {
$this->strategy->addComplexType($class);
}
// Auto-discover and output xml.
$discover = new AutoDiscover($this->strategy);
$discover->setBindingStyle(array('style' => 'document'));
$discover->setOperationBodyStyle(array('use' => 'literal'));
$discover->setClass($this->service);
$discover->setUri($this->endpoint);
$discover->setServiceName($this->name);
echo $discover->toXml();
} else {
$server = new Server($this->endpoint . '?wsdl');
// $server = new SoapServer($this->endpoint . '?wsdl', array(
// 'style' => SOAP_DOCUMENT,
// 'use' => SOAP_LITERAL,
// ));
// $server->setObject(new DocumentLiteralWrapped(new $this->service()));
// $server->handle();
$server->setClass(new DocumentLiteralWrapper(new $this->service()));
$server->registerFaultException($this->exceptions);
$server->setOptions($this->options);
// Intercept response, then decide what to do with it.
$server->setReturnResponse(true);
$response = $server->handle();
// Deal with a thrown exception that was converted into a SoapFault.
// SoapFault thrown directly in a service class bypasses this code.
if ($response instanceof SoapFault) {
$output->headers->set("Status", 500);
return self::serverFault($response);
} else {
return $response;
// echo $response;
}
}
laravel route generate wsdl use that in laravel for create soap client but it give fail tot load wsdl and when we use for Mobile app it return exception "HTTP request failed, HTTP status: 500"
Generate WSDL tag order using zend soap (same as zoap code)
<types> </types>
<portType> </portType>
<service> </service>
<message> </message>
it give soap action with #method name we use that for mobile
** Mobile App Code**
private val NAMESPACE = "http://10.2.0.114:8001/api/server/account-action";
private val METHODNAME = "withdrawDetail"
private val WSDL = "http://10.2.0.114:8001/api/server/account-action?wsdl";
private val SOAP_ACTION = "$NAMESPACE#$METHODNAME"
private val TAG = "soap"
var responseDump = ""
try {
val envelope = SoapSerializationEnvelope(SoapEnvelope.VER11)
val request = SoapObject(NAMESPACE, METHODNAME)
request.addProperty("withdrawId", "1")
request.addProperty("token", "695E8784AE45B219F62C4EBE21E3E")
val headerList: MutableList = ArrayList()
headerList.add(HeaderProperty("Content-Type", "application/xml; charset=UTF-8"))
headerList.add(
HeaderProperty(
"Authorization",
"Bearer " + "695E8784AE45B219F62C4EBE21E3E"
)
)
headerList.add(
HeaderProperty(
"Content-Type", "application/xml"
)
)
headerList.add(HeaderProperty("soapAction", NAMESPACE))
envelope.bodyOut = request
val transport = HttpTransportSE(WSDL)
transport.debug = true
try {
transport.call(SOAP_ACTION, envelope, headerList)
val requestDump = transport.requestDump
responseDump = transport.responseDump
Log.e(TAG, responseDump)
} catch (e: IOException) {
e.printStackTrace()
}
} catch (e: Exception) {
e.printStackTrace()
}
return responseDump
}