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 9013733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:20:32+00:00 2026-06-16T03:20:32+00:00

I am new to SOAP WSDL FUNCTIONS. I have a client who has been

  • 0

I am new to SOAP WSDL FUNCTIONS. I have a client who has been given a wsdl file from a company that deals in car testing. My client is a subcontractor for them. They have told us to upload the information about the car plate, category etc and once the details are sent through,There will be a response from server of either success or failure. Kindly assist in this.

Browsing through different information, I tried to do something like below but it is not working

    <?php
$data = array('1'=>'value','2'=>'value','3'=>'value','4'='value','5'=>'value');
$wsdl ='http://181.24.80.32/ws/services/servicename';
$client = new SoapClient($wsdl); 
$response = $client->servicenamerequest($data);  

echo $response->servicenamereturn;  
    ?>
  • 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-06-16T03:20:34+00:00Added an answer on June 16, 2026 at 3:20 am

    First of all: Go get SoapUI if you are dealing with an unknown Soap service. SoapUI will read the WSDL file and allow you to look at nearly everything related to Soap methods, parameters, and return values (if you dare to make a call to the live service – hopefully there is a sandbox server that does nothing critical).

    But SoapUI can help you there by creating a mock service that receives your request and responds with a canned request that you prepared. Here’s how I got from your linked WSDL to a working code example without touching the real service.

    Setting up SoapUI

    Create a new project in SoapUI and give the location of the WSDL. You might name this project.

    SoapUI then reads the contents of the WSDL and creates the project containing all described requests. After that you see what methods the service offers, and what kind of parameters have to go into it, as a tree. Opening this tree will get you to "Request 1" for every method detected, which displays some XML in the free version (paid version is slightly more comfortable with a form to fill) like this (from the vehiclePassedTest method):

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tr="http://tr.gov.tp.stp.ws.PassedVehicleTestService">
       <soapenv:Header>
          <tr:password>?</tr:password>
          <tr:username>?</tr:username>
       </soapenv:Header>
       <soapenv:Body>
          <tr:vehiclePassedTest>
             <chassisNo>?</chassisNo>
             <plateNo>?</plateNo>
             <plateCode>?</plateCode>
             <plateCategory>?</plateCategory>
             <plcEmiCode>?</plcEmiCode>
             <currentUserName>?</currentUserName>
          </tr:vehiclePassedTest>
       </soapenv:Body>
    </soapenv:Envelope>
    

    The questionmarks are where you have to provide data. This request structure has to be created by you using the SoapClient of PHP.

    Let’s mock this. Mocking means that SoapUI starts it’s own Soap server that accepts requests. It usually runs on 127.0.0.1:8080. Right-click on the project "PassedVehicleTestService" and select "New MockService". Accept the name, press Ok.

    Right-click on the method you want to mock. Select "Add to mock service" and select the created one from the previous step. Answer yes to open the mock response editor. There you see the XML structure of the answer, with question marks for the data that the service will fill out. All the responses from this service allow one answer as a string, so write something nice that will be returned. You can add the other methods to this service later if needed.

    Right-click your "MockService 1" and select "Start minimized". This will start the Soap server, it will wait for an incoming request.

    Setup PHP SoapClient for the mock.

    You need to know two things. First the location of the WSDL. This file contains the address of the real server to be used for the requests, but PHP allows to override this. So the second info you need is the address of the running mock service.

    SoapUI displays the address from the WSDL in the request editor. In your case it is http://181.24.80.32/ws/services/PassedVehicleTestService – the mock service runs on http://127.0.0.1:8080/ws/services/PassedVehicleTestService – IP and port is replaced, the path is kept.

    This leads to the first lines of PHP code:

    $options = array(
        'location' => 'http://127.0.0.1:8080/ws/services/PassedVehicleTestService',
    );
    
    $client = new SoapClient("http://www.quickregistration.ae/temp/PassedVehicleTestService.xml", $options);
    

    After that you have a configured SoapClient able to talk to your mock service. If later you want to use the real service, throw the line with "location" out of the array, and keep the other config parameters if you happen to add some.

    Talk to the mock

    With the client, you can do $client->nameOfSoapMethod(paramStructure). The parameter structure usually is a mixture of arrays or objects and scalar values like strings. So that’s what I try first:

    $result = $client->vehiclePassedTest(array());
    var_dump($result);
    

    Then I look at SoapUI to see what happens. Output from the php script:

    Notice: Array to string conversion in [...]/soap.php on line 20
    string(1) "?"
    

    SoapUI says:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tr.gov.tp.stp.ws.PassedVehicleTestService">
        <SOAP-ENV:Body>
            <ns1:vehiclePassedTest>
                <chassisNo>Array</chassisNo>
                <plateNo/>
                <plateCode/>
                <plateCategory/>
                <plcEmiCode/>
                <currentUserName/>
            </ns1:vehiclePassedTest>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    That was not the right approach. The array got converted into a string "Array", and was placed as the first parameter. The rest is empty. Nice, because I know that soap calls may accept more that one parameter, and this is one of these services.

    $result = $client->vehiclePassedTest('chassisNo', 'plateNo', 'plateCode', 'plateCategory', 'plcEmiCode', 'currentUserName');
    

    This shows up correctly in SoapUI, but the headers are still missing.

    Adding SoapHeader to the request

    The SoapClient offers a method named __setSoapHeaders(), and there is a class SoapHeader.

    The description says that setSoapHeaders() accepts one SoapHeader object or an array of SoapHeader objects. Let’s create one, pass it and see what happens:

    $username = new SoapHeader();
    $client->__setSoapHeaders($username);
    $result = $client->vehiclePassedTest('chassisNo', 'plateNo', 'plateCode', 'plateCategory', 'plcEmiCode', 'currentUserName');
    var_dump($result);
    

    PHP says: Warning: SoapHeader::SoapHeader() expects at least 2 parameters, 0 given

    $username = new SoapHeader('namespace', 'username', 'MyUserName');
    

    This works. SoapUI says:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tr.gov.tp.stp.ws.PassedVehicleTestService" xmlns:ns2="namespace">
        <SOAP-ENV:Header>
            <ns2:username>MyUserName</ns2:username>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <ns1:vehiclePassedTest><chassisNo>chassisNo</chassisNo><plateNo>plateNo</plateNo><plateCode>plateCode</plateCode><plateCategory>plateCategory</plateCategory><plcEmiCode>plcEmiCode</plcEmiCode><currentUserName>currentUserName</currentUserName></ns1:vehiclePassedTest>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    Note the TWO xmlns attributes in the SOAP-ENV:Envelope element. The original request requires the username be in the namespace "tr" – but "tr" is only a shortcut to the string that is defined as "xlmns:tr" – the string behind this is your namespace needed (although it might already work with the real service).

    $username = new SoapHeader("http://tr.gov.tp.stp.ws.PassedVehicleTestService", 'username', 'myUser');
    $password = new SoapHeader("http://tr.gov.tp.stp.ws.PassedVehicleTestService", 'password', 'yetAnotherPassword');
    $client->__setSoapHeaders(array($username, $password));
    

    This correctly defines the headers, as you can see:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tr.gov.tp.stp.ws.PassedVehicleTestService">
        <SOAP-ENV:Header>
            <ns1:username>myUser</ns1:username>
            <ns1:password>yetAnotherPassword</ns1:password>
        </SOAP-ENV:Header>
        <SOAP-ENV:Body>
            <ns1:vehiclePassedTest><chassisNo>chassisNo</chassisNo><plateNo>plateNo</plateNo><plateCode>plateCode</plateCode><plateCategory>plateCategory</plateCategory><plcEmiCode>plcEmiCode</plcEmiCode><currentUserName>currentUserName</currentUserName></ns1:vehiclePassedTest>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    No two namespaces in the envelope element, and every element is of namespace "ns1". This should work.

    Your final code:

    $options = array(
        'location' => 'http://127.0.0.1:8080/ws/services/PassedVehicleTestService',
    );
    
    $client = new SoapClient("http://www.quickregistration.ae/temp/PassedVehicleTestService.xml", $options);
    
    $username = new SoapHeader("http://tr.gov.tp.stp.ws.PassedVehicleTestService", 'username', 'myUser');
    $password = new SoapHeader("http://tr.gov.tp.stp.ws.PassedVehicleTestService", 'password', 'yetAnotherPassword');
    $client->__setSoapHeaders(array($username, $password));
    
    $result = $client->vehiclePassedTest('chassisNo', 'plateNo', 'plateCode', 'plateCategory', 'plcEmiCode', 'currentUserName');
    
    var_dump($result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a SOAP client like so: $client = new SoapClient(file.wsdl); And then when
I'm fairly new to the SOAP and WSDL world. What do I have to
I have a wsdl file and i am trying to call it from a
This problem has been killing me for the entire day. I have a client
so I have a WSDL I've been giving as documentation for a soap service.
Basic PHP function: //SOAP CALL function sayHello(){ $client = new SoapClient('http://Server:8080/MyClassService/MyClass?WSDL'); $response = $client->glassfishHello();
I am new to using soap. I have a soap method returning an object.
I have the following XML: <Result ID=1,New xmlns=http://schemas.microsoft.com/sharepoint/soap/> <ErrorCode>0x00000000</ErrorCode> <ID /> <z:row ows_ID=6 />
New to PHP and MySQL, have heard amazing things about this website from Leo
I have to send a byte array (encoded photo) from my PHP client to

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.