Skip to content
Advertisement

Remove tag, in submitting data to Soap Server with PHP

Actual result:

JavaScript

Expected result without <return xsi:type="SOAP-ENC:Struct"></return> tag.

I am doing it first time, and actually I know almost nothing about Soap Server, could you tell me, how can I remove return tag ?

this is the code on server side:

JavaScript

Advertisement

Answer

In order to do what you want you must make a WSDL document and pass it both to the server and the client. Let’s start creating a WSDL document named wsdl-pruebas.wsdl with the following content:

JavaScript

The definition seems overwhelming, but it’s quite simple once you analize it section by section, which we’ll analize below. First we define the type for the response here:

JavaScript

As you can see it’s identical to your class. We’ll use it later. Next we define the request and response messages:

JavaScript

We’re defining an empty request, but a response of the type of your class. Take note of the name attribute, which values return. This is what you currently see in the response of the server. Next we define the “interface” for the operations of your SOAP server:

JavaScript

input and output simply point to the messages described above. Next we define the “details” of the portType:

JavaScript

Here soap:binding tells us it’s using SOAP 1.1.

Finally we expose the binding through the service section:

JavaScript

The soap:address point to the URL of your soap server script (in this example, http://localhost/pruebas/soap-server.php).

After defining the WSDL document, we code the soap server script (in this example will be named soap-server.php):

JavaScript

This time we provide the URL of our WSDL document and modify the $options array.

To see all this in action we create a SOAP client script (in this example will be soap-client.php):

JavaScript

Again, we specify the URL of our WSDL document. Running the client script will give this:

JavaScript

What differs from the generated response of your soap server script?

In the soap:binding definition, if we modify the value of the stylesttribute to from document to rpc:

JavaScript

We’ll get this response:

JavaScript

Which is the response you’re getting currently.

EDIT: Lastly, if we change the soap:body line:

JavaScript

to this:

JavaScript

The response will be:

JavaScript

NOTE: For this I’m assuming the scripts and the WDSL are located in http://localhost/pruebas/.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement