cancel
Showing results for 
Search instead for 
Did you mean: 

Using NuSOAP (PHPED) to access webservices from SAP

Former Member
0 Kudos

Hi all,

I am doing some investigation on the possibilities to further integrate SAP and PHP through webservices. I am using PHPED to code in PHP, which has an integrated wizard to use NuSOAP by reading WSDL files, and so creating PHP code and WS-stubs.

I cannot get it working ... does anyone has a tip for me? It might be due to an authorization issue, but when I use the same WSDL in e.g. FLEX, I need to log on and thus working fine. I neither have SSO on this machine (using NSP trial).

This is my code (using a flight webservice ofcourse ;): (your feedback is appreciated!!!)

WS_FLIGHT PHP code:

<?php

// Nusoap library 'nusoap.php' should be available through include_path directive

require_once('nusoap.php');

// set the URL or path to the WSDL document

$wsdl = "http://localhost:8000/sap/bc/srt/rfc/sap/Z_FLIGHT_WS?wsdl";

// instantiate the SOAP client object

$soap = new soapclient($wsdl,"wsdl");

// set credentials

$soap->setCredentials("BCUSER","minisap");

// get the SOAP proxy object, which allows you to call the methods directly

$proxy = $soap->getProxy();

// set parameter parameters (FlightGetList^)

$parameters = array(Airline=>"LH",DateRange=>"",DestinationFrom=>"",DestinationTo=>"",ExtensionIn=>"",MaxRows=>0);

// get the result, a native PHP type, such as an array or string

$result = $proxy->FlightGetList($parameters);

print_r($result);

?>

NOTE: I've got a structure like this working for a public WSDL, example of that code below:

WORKING CODE:

<?php

// Nusoap library 'nusoap.php' should be available through include_path directive

require_once('nusoap.php');

// set the URL or path to the WSDL document

$wsdl = "http://www.webservicex.net/WeatherForecast.asmx?WSDL";

// instantiate the SOAP client object

$soap = new soapclient($wsdl,"wsdl");

// get the SOAP proxy object, which allows you to call the methods directly

$proxy = $soap->getProxy();

// set parameter parameters (GetWeatherByZipCode^)

$parameters = array(ZipCode=>10001);

// get the result, a native PHP type, such as an array or string

$result = $proxy->GetWeatherByZipCode($parameters);

print_r($result);

?>

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Just wondered if there was a particular reason for not using the PHP standard SOAP client as Iu2019ve used this successfully on a couple of projects.

http://www.mattbartlett.co.uk/setting-up-soap-in-sap-and-connecting-with-php/

http://www.youtube.com/watch?v=GG85rUbhXMg

Former Member
0 Kudos

I realize how old this question is, but it is relevant to my interests.

First: SAP does not seem to allow the nuSOAP proxy method:

$proxy = $soap->getProxy();

You have to instead use nuSOAP's SOAP client call method:

$result = $sapClient->call('function',$param);

I'm having trouble passing in parameters though. I'm consistently getting an error that I'm not passing in a certain parameter, when I certainly am. I have success using PHP's SOAP extension, but that option is not available to me at this time. As of now, nuSOAP is my only option with the current web hosting server I'm working with, and passing parameters does not seem to be as simple as with the built in php SOAP extension.

This is the error message I'm getting:

array(3) {
  ["faultcode"]=>
  string(15) "soap-env:Server"
  ["faultstring"]=>
  array(2) {
    ["!xml:lang"]=>
    string(2) "en"
    ["!"]=>
    string(86) "CX_ST_GROUP_MISSING_CASE:XSLT exception.Element 'PurchaseRequestSelectionByID' missing"
  }

Does anybody know why this keeps happening? Also, is it just me or is consuming web services from SAP services very slow?