Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6825551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:02:41+00:00 2026-05-26T22:02:41+00:00

I’m trying to create a simple SOAP webservice in PHP using the native SoapServer

  • 0

I’m trying to create a simple SOAP webservice in PHP using the native SoapServer class: http://www.php.net/manual/en/class.soapserver.php

However, the documentation is very poor on this class and i have no idea on how to create a Server, just a client. Can anyone provide some tuts or sample code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:02:41+00:00Added an answer on May 26, 2026 at 10:02 pm

    I have also been struggling with this, especially getting code that works well with .Net clients. I have found examples that work well with PHP clients, but often these examples fail when I try to call the service from a .Net client. I am still struggling with this, hence this question of mine asking for help with a simple PHP SoapServer example that returns a string value:

    String values returned by PHP SoapServer not received by .Net client

    But, although I can’t get this basic example working, I have managed to get an example working that returns an array of custom object, so I will share this example here in the hope that it will be helpful to others. This example defines a single operation getUsers which takes a string parameter message, just to demonstrate message passing. This operation returns an array of User objects. The User object also has a field message where I pass back the value received into the service, just for testing purposes. I will post the complete example; wsdl document, PHP server code and C# client code.

    WSDL Document

    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
        xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
        xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
        xmlns:tns="http://test-uri/soap/export/"
        xmlns:s="http://www.w3.org/2001/XMLSchema"
        xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
        xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
        targetNamespace="http://test-uri/soap/export/"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    
    <wsdl:types>
    <s:schema targetNamespace="http://test-uri/soap/export/" elementFormDefault="qualified">
        <s:import namespace="http://microsoft.com/wsdl/types/"/>
    
        <s:element name="getUsers">
            <s:complexType>
                <s:sequence>
                    <s:element minOccurs="1" maxOccurs="1" name="message" type="s:string"/>
                </s:sequence>
            </s:complexType>
        </s:element>
    
        <s:element name="getUsersResponse">
            <s:complexType>
                <s:sequence>
                    <s:element name="getUsersArray" type="tns:getUsersArray"/>
                </s:sequence>
            </s:complexType>
        </s:element>
    
        <s:complexType name="getUsersArray">
            <s:sequence>
                <s:element minOccurs="0" maxOccurs="unbounded" name="User" nillable="true" type="tns:User" />
            </s:sequence>
        </s:complexType>
    
        <s:complexType name="User">
            <s:sequence>
                <s:element minOccurs="1" maxOccurs="1" name="id" type="s:string"/>
                <s:element minOccurs="1" maxOccurs="1" name="firstname" type="s:string"/>
                <s:element minOccurs="1" maxOccurs="1" name="surname" type="s:string"/>
                <s:element minOccurs="1" maxOccurs="1" name="message" type="s:string"/>
            </s:sequence>
        </s:complexType>
    </s:schema>
    </wsdl:types>
    
    <wsdl:message name="getUsersSoapIn">
    <wsdl:part name="parameters" element="tns:getUsers"/>
    </wsdl:message>
    <wsdl:message name="getUsersSoapOut">
    <wsdl:part name="parameters" element="tns:getUsersResponse"/>
    </wsdl:message>
    
    <wsdl:portType name="TestSoap">
    <wsdl:operation name="getUsers">
        <wsdl:documentation xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
            Function ("getUsers")
        </wsdl:documentation>
        <wsdl:input message="tns:getUsersSoapIn"/>
        <wsdl:output message="tns:getUsersSoapOut"/>
    </wsdl:operation>
    </wsdl:portType>
    
    <wsdl:portType name="TestSoap12">
    <wsdl:operation name="getUsers">
        <wsdl:documentation xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
            Function ("getUsers")
        </wsdl:documentation>
        <wsdl:input message="tns:getUsersSoapIn"/>
        <wsdl:output message="tns:getUsersSoapOut"/>
    </wsdl:operation>
    </wsdl:portType>
    
    <wsdl:binding name="TestSoap" type="tns:TestSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getUsers">
        <soap:operation soapAction="http://test-uri/soap/export/getUsers" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    
    <wsdl:binding name="TestSoap12" type="tns:TestSoap12">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getUsers">
        <soap12:operation soapAction="http://test-uri/soap/export/getUsers" style="document"/>
        <wsdl:input>
            <soap12:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap12:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    </wsdl:binding>
    
    <wsdl:service name="TestService">
    <wsdl:port name="TestPort" binding="tns:TestSoap">
        <soap:address location="http://url/to/test_server.php"/>
    </wsdl:port>
    <wsdl:port name="TestSoap12" binding="tns:TestSoap12">
        <soap12:address location="http://url/to/test_server.php"/>
    </wsdl:port>
    </wsdl:service>
    
    </wsdl:definitions>
    

    PHP Server Code

    <?php
    function getUsers($args) {
       $args = (array)$args;
       return array("getUsersArray" => array(  
                                           array("id"=>"1",
                                               "firstname"=>"Barney",
                                               "surname"=>"Rubble",
                                               "message"=>$args["message"]), 
                                           array("id"=>"2", 
                                                "firstname"=>"Fred", 
                                                "surname"=>"Flintstone", 
                                                "message"=>$args["message"])
                                        )
                   );
    }
    ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
    $server = new SoapServer("test.wsdl");
    $server->addFunction("getUsers");
    try {
        $server->handle();
    }
    catch (Exception $e) {
        $server->fault('Sender', $e->getMessage());
    }
    ?>
    

    C# Client Code

    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                WebReference.TestService srv = new WebReference.TestService();
                WebReference.User[] users = srv.getUsers("says hello");
                foreach (WebReference.User user in users)
                {
                    MessageBox.Show(user.firstname+" "+user.message);
                }
            }
        }
    }
    

    That’s it. I hope this example is useful to others and saves them the hours that this has cost me!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.