SOAP Server Struggling

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
PhilAJ52
New php-forum User
New php-forum User
Posts: 1
Joined: Fri Feb 23, 2018 7:53 am

Fri Feb 23, 2018 8:18 am

I'm trying to create a SOAP Server that will process requests from another system. The system sends a SOAP Envelope of XML in and I need to extract the fields and do some processing.

Don't fully understand the WSDL they have provided - but I have created the following basic server code (See below) - which appears to run - and some debugging shows that it is called.

At debug point 0 - outputs a text file containing 'here' - and at point 1 outputs text file containing the XML as below.

BUT - My function never seems to be called - is there something basic I'm missing?

Please any help much appreciated



Code: Select all

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><DynamicChange><VTID>5572</VTID><ExtID>5572</ExtID><FunctionCode>5</FunctionCode><Status>3</Status><FMExtID>WIECR</FMExtID><Termin_von>2018-02-21T00:00:00+00:00</Termin_von><Termin_bis>2018-02-23T00:00:00+00:00</Termin_bis><Plandauer>480</Plandauer><Besuchsdauer>480</Besuchsdauer><Planankunft>2018-02-27T09:00:00+00:00</Planankunft><Infotext></Infotext></DynamicChange></soap:Body></soap:Envelope>

Code: Select all

<?php

// turn off WSDL caching
ini_set("soap.wsdl_cache_enabled","0");

//Function to write a debug file
function wdf($no, $text) 
{	
    $fp = fopen('test'.$no.'.txt', 'w');
    fwrite($fp, $text);
    fclose($fp);	
}

// Main Function
function DynamicChange($change)
{
	wdf("2","here");		// Debug Write 2
	
	$VTID = $change->VTID;
	$ExtID = $change->ExtID;
	$FunctionCode = $change->FunctionCode;
	$Status = $change->Status;
	$FMExtID = $change->FMExtID;
	$Termin_von = $change->Termin_von;
	$Termin_bis=$change->Termin_bis;
	$Plandauer = $change->Plandauer;
	$Besuchsdauer = $change->Besuchsdauer;
	$Planankunft = $change->Planankunft;
	$Infotext = $change->Infotext;	
		
	// Process it 	
	
	wdf("3",$ExtID);		// Debug Write 3
	Return ['DynamicChangeRequestResult' => 0];
		
}

wdf("0","here");		// Debug Write 0

$postdata = file_get_contents("php://input");
wdf("1",$postdata);		// Debug Write 1
		
// initialize SOAP Server
$server=new SoapServer("AspDynamicServer.wsdl");
$server->addFunction('DynamicChange');

// start handling requests
$server->handle();
?>

Post Reply