cancel
Showing results for 
Search instead for 
Did you mean: 

Need help connecting to a XI webservice

Former Member
0 Kudos

Hi there everyone! I'm having trouble when trying to connect to a XI webservice. I'll try to explain it.

I'm running a W2003 machine with IIS and PHP 5.2.3 running on it. php_soap.dll extension is enabled on it.

The WSDL location is and url at our XI system and looks like this:

http://benelus:50100/XISOAPAdapter/MessageServlet?channel=:BSANET_DEV:bsanet_CrearReserva_SOAP_Clien...

I think i can't call the constructor of SoapClient in WSDL mode, so I call it that way:

$_param_client_opt = array(

'location' => "http://benelus:50100/XISOAPAdapter/MessageServlet?channel=:BSANET_DEV:bsanet_CrearReserva_SOAP_Client&version=3.0",

'uri' => "urn:bsa:bsanet"

);

$oSoapClient = new SoapClient(null,$_param_client_opt);

Looks like there's no problem in here. Now i need to call a function in there to create a material(the name of the method is "os_ReservaMaterialCrear"). I have the xml file with all the structure but I don't know how to make it work. I have tried this:

$xml = file_get_contents("documento.xml");

$oSoapClient->__soapCall("os_ReservaMaterialCrear",$xml);

I'm not getting any errors but the message isn't arriving to XI. Any ideas? Maybe i need to use __doRequest??

Any help will be apreciated! Thanks in advance for help!

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Well, I solved it! At the end used nusoap to solve it.

The php code:

require_once("../recursos/lib/nusoap.php");
$proxyhost = isset($_POST["proxyhost"]) ? $_POST["proxyhost"] : "";
$proxyport = isset($_POST["proxyport"]) ? $_POST["proxyport"] : "";
$proxyusername = isset($_POST["proxyusername"]) ? $_POST["proxyusername"] : "";
$proxypassword = isset($_POST["proxypassword"]) ? $_POST["proxypassword"] : "";
$useCURL = isset($_POST["usecurl"]) ? $_POST["usecurl"] : "0";
$client = new nusoap_client("http://benelus:50100/XISOAPAdapter/MessageServlet?channel=:BSANET_DEV:bsanet_CrearReserva_SOAP_Client&version=3.0", false,
						$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
	echo "<h2>Constructor error</h2><pre><code>" . $err . "</code></pre>";
	echo "<h2>Debug</h2><pre><code>" . htmlspecialchars($client->getDebug(), ENT_QUOTES) . "</code></pre>";
	exit();
}
$client->setCredentials("xi_bsanet","xi_bsanet"); 
$client->setUseCurl($useCURL);

	$XMLstring = '<urn:CrearReserva xmlns:urn="urn:bsa:bsanet">';
	$XMLstring =$XMLstring ."<usuario>JORDI</usuario>";
	$XMLstring =$XMLstring ."<sistema>BSANET</sistema>";
	$XMLstring =$XMLstring ."<destinatario>PERE</destinatario>";
	$XMLstring =$XMLstring ."<pos_reservas>";
	$XMLstring =$XMLstring ."<centro_coste>1EMH330404</centro_coste>";
	$XMLstring =$XMLstring ."<material>10000485</material>";
	$XMLstring =$XMLstring ."<almacen>MAGC</almacen>";
	$XMLstring =$XMLstring ."<cantidad>100</cantidad>";
	$XMLstring =$XMLstring ."</pos_reservas>";
	$XMLstring =$XMLstring ."<pos_reservas>";
	$XMLstring =$XMLstring ."<centro_coste>1EMH330404</centro_coste>";
	$XMLstring =$XMLstring ."<material>10000486</material>";
	$XMLstring =$XMLstring ."<almacen>MAGC</almacen>";
	$XMLstring =$XMLstring ."<cantidad>100</cantidad>";
	$XMLstring =$XMLstring ."</pos_reservas>";			
	$XMLstring =$XMLstring ."</urn:CrearReserva>";

	$soapaction = "http://sap.com/xi/WebService/soap1.1"; 
	
	$mysoapmsg = $client->serializeEnvelope($XMLstring,'',array(),'document', 'literal');
        $result = $client->send($mysoapmsg,$soapaction);


if ($client->fault) {
	echo "<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre><code>"; print_r($result); echo "</code></pre>";
} else {
	$err = $client->getError();
	if ($err) {
		echo "<h2>Error</h2><pre><code>" . $err . "</code></pre>";
	} else {
		echo "<h2>Result</h2><pre><code>"; print_r($result); echo "</code></pre>";
	}
}
echo "<h2>Request</h2><pre><code>" . htmlspecialchars($client->request, ENT_QUOTES) . "</code></pre>";
echo "<h2>Response</h2><pre><code>" . htmlspecialchars($client->response, ENT_QUOTES) . "</code></pre>";
echo "<h2>Debug</h2><pre><code>" . htmlspecialchars($client->getDebug(), ENT_QUOTES) . "</code></pre>";

Notice i had to remove the soapenv tags from the xml string and include the namespace in the first xml tag. Had to config the XI to not expect the soapenv tag and it finally worked.

Hope it helps someone. Cheers from Catalonia!

Edited by: Jordi Morell on Dec 4, 2008 9:14 AM

Former Member
0 Kudos

Well, XI is getting messages at least now. The source code I'm using now it's the following:

	$usuario = "PRUEBA";
	$sistema = "BSANET";
	$destinatario = "Juan";
	$centro_coste = "1EMH330404";
	$material = "100000030";
	$almacen = "MAGC";
	$cantidad = "2";

	$_param_client_opt = array( 
	  //HTTP connection through a proxy server
	  'location' => "http://benelus:50100/XISOAPAdapter/MessageServlet?channel=:BSANET_DEV:bsanet_CrearReserva_SOAP_Client&amp;version=3.0",
	  'login' => "xi_bsanet",
	  'password' => "xi_bsanet",
	  'uri' => "urn:bsa:bsanet",
	  'style' => SOAP_DOCUMENT,
	  'use' => SOAP_LITERAL,
	  'trace' => true,
	  'exceptions' => true
	);
	
	$oSoapClient = new SoapClient(null,$_param_client_opt);
		try {
	
	$oSoapClient->__soapCall(	        
	        "os_ReservaMaterialCrear",
	       
	        array(
	            new SoapParam(
	                
	                "PRUEBA",
	                
	                "usuario" ),
	            new SoapParam(
	               
	                "BSANET",
	                
	                "sistema" ),	                
	            new SoapParam(
	                
	                "Juan",
	                
	                "destinatario" ),	
	            new SoapParam(
	                
	                "1EMH330404",
	               
	                "centro_coste" ),	                
	            new SoapParam(
	               
	                "100000030",
	                
	                "material" ),	                
	            new SoapParam(
	                
	                "MAGC",
	                
	                "almacen" ),	                
	            new SoapParam(
	                
	                "2",
	                
	                "cantidad" )	                                

	       )); 
		
		}
		catch (SoapFault $e) {
		 echo 'Caught an Error: [' . $e->faultcode . '] - ' . $e->faultstring;
		}	

I'm getting that error: Caught an Error: [SOAP:Server] - Server Error

The expected XML file should look like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:bsa:bsanet">
<soapenv:Header/>
<soapenv:Body>
<urn:CrearReserva>
<usuario>PRUEBA</usuario>
<sistema>BSANET</sistema>
<destinatario>Juan</destinatario>
<!--1 or more repetitions:-->
<pos_reservas>
<centro_coste>1EMH330404</centro_coste>
<material>100000030</material>
<almacen>MAGC</almacen>
<cantidad>2</cantidad>
</pos_reservas>
<pos_reservas>
<centro_coste>1EMH133010</centro_coste>
<material>10000023</material>
<almacen>MAGC</almacen>
<cantidad>3</cantidad>
</pos_reservas>
<pos_reservas>
<centro_coste>1EMH330404</centro_coste>
<material>10000023</material>
<almacen>MAGC</almacen>
<cantidad>2</cantidad>
</pos_reservas>
</urn:CrearReserva>
</soapenv:Body>
</soapenv:Envelope>

The XML i get in XI looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> 
- <!--  Request Message Mapping 
  --> 
- <param0 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
- <item>
  <key>usuario</key> 
  <value>PRUEBA</value> 
  </item>
- <item>
  <key>sistema</key> 
  <value>BSANET</value> 
  </item>
- <item>
  <key>destinatario</key> 
  <value>Juan</value> 
  </item>
- <item>
  <key>centro_coste</key> 
  <value>1EMH330404</value> 
  </item>
- <item>
  <key>material</key> 
  <value>100000030</value> 
  </item>
- <item>
  <key>almacen</key> 
  <value>MAGC</value> 
  </item>
- <item>
  <key>cantidad</key> 
  <value>2</value> 
  </item>
  </param0>

I think i can work in XI to read the message in a different way, but I think it would be better to send it properly. Any ideas?

Thanks in advance for help.

Edited by: Jordi Morell on Nov 20, 2008 2:29 PM

Edited by: Jordi Morell on Dec 4, 2008 9:12 AM