I try to make custom webservice, begin from nothing no working, now i try to services.

I create the soap server in this form

Install service module and soap_server dev module.

Create webservice soap


create api service

 * Implements hook_ctools_plugin_api().
function core_custom_webservice_ctools_plugin_api($owner, $api) {
  if ($owner == 'services' && $api == 'services') {
    return array(
      'version' => 3,
      'file' => 'my_module.services.inc'

later create own service in core_custom_webservice.services.inc

function core_custom_webservice_services_resources() {
  $resources = array(
    'core_custom_webservice_resources' => array(
      'actions' => array(
        'response_word' => array(
          'help' => t('Response of webservice'),
          'file' => array(
            'type' => 'inc',
            'module' => 'core_custom_webservice',
            'name' => 'core_custom_webservice.resource',
          'callback' => 'core_custom_webservice_get_response',
          'args' => array(),
          'access callback' => '_node_resource_access',
          'access arguments' => array('view'), 
          'access arguments append' => TRUE,
  return $resources;

and later core_custom_webservice.resource.inc

function core_custom_webservice_get_response($response) {
  return 'print '.$response;

Later i visit resources in ui admin services, and enable my own resource

own resource

and later visit link of my service, the link is /endpoint_path

error service endpoint

and later i try to debug visit url /soap_server/debug_wsdl/endpoint_name

make this xml

    <?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:tns="urn:soap_server" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="soap_server" targetNamespace="urn:soap_server">
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:soap_server"/>
  <message name="core_custom_webservice_resources_soap_response_word_request"> </message>
  <message name="core_custom_webservice_resources_soap_response_word_response">
    <part name="response_object" type="xsd:struct"/>
  <portType name="soap_server_port_type">
    <operation name="core_custom_webservice_resources_soap_response_word">
      <input message="tns:core_custom_webservice_resources_soap_response_word_request"/>
      <output message="tns:core_custom_webservice_resources_soap_response_word_response"/>
  <binding name="soap_server_binding" type="tns:soap_server_port_type">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="core_custom_webservice_resources_soap_response_word">
      <soap:operation soapAction="urn:xmethods-delayed-quotes#core_custom_webservice_resources_soap_response_word"/>
        <soap:body use="literal" namespace="urn:xmethods-delayed-quotes"/>
        <soap:body use="literal" namespace="urn:xmethods-delayed-quotes"/>
  <service name="soap_server_service">
    <port name="soap_server_port" binding="tns:soap_server_binding">
      <soap:address location=""/>

and later of this, i dont know how i can make, please any solution, i try to make all step by step for make this functional.

this is my client


$echo = $_GET['input'];

print "<h2>Echo Web Service</h2>";
print "<form action='client.php' method='GET'/>";
print "<input name='input' value='$echo'/><br/>";
print "<input type='Submit' name='submit' value='GO'/>";
print "</form>";

print "</form>";

if($echo != ''){
    $client = new SoapClient(null, array(
      'location' => "",
      'uri'      => "urn:soap_server"));

    $result = $client->__soapCall("core_custom_webservice_resources_soap_response_word",array($echo));

    print $result;
  • Also do you want this inside a block? – Matt Jan 31 '17 at 22:27
  • It doesn't make much sense to put that into Drupal - why do you need to? You're not using the API, you need to bypass the normal request workflow, it's just not a good fit – Clive Jan 31 '17 at 22:38
  • You're much better off using the Services module. It's extremely well built. Why re-invent the wheel? – Jaypan Feb 1 '17 at 2:29
  • Hi @Jaypan How can construct this in services, with custom methods and soap – jonathan Feb 1 '17 at 14:17
  • Here's the module: drupal.org/project/services, here is the documentation, drupal.org/node/109782, and here is the SOAP server that integrates with it: drupal.org/project/soap_server – Jaypan Feb 1 '17 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.