Skip to content

Instantly share code, notes, and snippets.

@dwaghmare
Forked from tomflanagan/sap
Created January 22, 2016 15:00
Show Gist options
  • Save dwaghmare/f85c8568452cd5c25ca8 to your computer and use it in GitHub Desktop.
Save dwaghmare/f85c8568452cd5c25ca8 to your computer and use it in GitHub Desktop.
Example of extending wsclient.
<?php
function sap_soap_menu() {
$items['sap/getusers'] = array(
'page callback' => 'sap_soap_users',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function sap_soap_users() {
$parameters = array(
'Iname' => 'chenx',
'TAppuser' => array(
'Mandt' => '700',
'UserId' => '5094',
'UserName' => 'chenxh5094',
'Age' => ''
),
);
$return = '';
$service = wsclient_service_load('sap_user_get');
$result = $service->ZRemotingAppuser($parameters);
print_r($result);
foreach($result as $r) {
foreach ($r->item as $item) {
$return .= $item->UserName .'<br />';
}
}
//$res = print_r($result);
return $return;
}
/**
* Implements hook_wsclient_endpoint_types.
*/
function sap_soap_wsclient_endpoint_types() {
//die('test');
return array(
'tomsoap' => array(
'label' => t('Tom SOAP'),
'class' => 'SAPSOAPEndpoint',
),
);
}
/**
* A remote endpoint type for invoking SOAP services.
*/
class SAPSOAPEndpoint extends WSClientSOAPEndpoint {
public function client() {
$this->client = parent::client();
$this->client->__setLocation('the_correct_address');
return $this->client;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment