Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Names of elements in soap:body are incorrect #15

Closed
MudrakIvan opened this issue Jul 19, 2024 · 4 comments · Fixed by #16
Closed

Names of elements in soap:body are incorrect #15

MudrakIvan opened this issue Jul 19, 2024 · 4 comments · Fixed by #16

Comments

@MudrakIvan
Copy link

MudrakIvan commented Jul 19, 2024

Bug Report

Q A
BC Break yes
Version 0.6.0

Summary

Soap body is always generated with one element which is named after called operation. This behaviour is not correct, when input message of the operation has defined its part (info about message parts).

Current behaviour

Currently, the body element always has only one child which is named after the operation name.

How to reproduce

To reproduce, use wsdl which contains message defintion with parts. To reproduce, you can use this simple wsdl:

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tns="http://example.com/customerdetails"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://example.com/customerdetails"
    name="CustomerDetailsService">

    <!-- Data Types -->
    <types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://example.com/customerdetails">
            <element name="GetCustomerDetailsRequest">
                <complexType>
                    <sequence>
                        <element name="customerId" type="xsd:string" />
                    </sequence>
                </complexType>
            </element>
            <element name="GetCustomerDetailsResponse">
                <complexType>
                    <sequence>
                        <element name="customerName" type="xsd:string" />
                        <element name="customerEmail" type="xsd:string" />
                    </sequence>
                </complexType>
            </element>
        </schema>
    </types>

    <!-- Message Definitions -->
    <message name="GetCustomerDetailsRequestMessage">
        <part name="parameters" element="tns:GetCustomerDetailsRequest" />
    </message>
    <message name="GetCustomerDetailsResponseMessage">
        <part name="parameters" element="tns:GetCustomerDetailsResponse" />
    </message>

    <!-- Port Type (Abstract Interface) -->
    <portType name="CustomerDetailsPortType">
        <operation name="GetCustomerDetails">
            <input message="tns:GetCustomerDetailsRequestMessage" />
            <output message="tns:GetCustomerDetailsResponseMessage" />
        </operation>
    </portType>

    <!-- Binding (Concrete Implementation) -->
    <binding name="CustomerDetailsBinding" type="tns:CustomerDetailsPortType">
        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
        <operation name="GetCustomerDetails">
            <soap:operation soapAction="http://example.com/GetCustomerDetails" />
            <input>
                <soap:body use="literal" />
            </input>
            <output>
                <soap:body use="literal" />
            </output>
        </operation>
    </binding>

    <!-- Service Definition -->
    <service name="CustomerDetailsService">
        <documentation>This service provides customer details based on customer ID.</documentation>
        <port name="CustomerDetailsPort" binding="tns:CustomerDetailsBinding">
            <soap:address location="http://example.com/customerdetails/service" />
        </port>
    </service>
</definitions>

When operation GetCustomerDetails is called, soap request should look like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:tns="http://example.com/customerdetails">
    <soapenv:Header />
    <soapenv:Body>
        <tns:GetCustomerDetailsRequest>
            <customerId>12345</customerId>
        </tns:GetCustomerDetailsRequest>
    </soapenv:Body>
</soapenv:Envelope>

But currently it looks like this:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
        <tns:GetCustomerDetails xmlns:tns="http://example.com/customerdetails">
            <customerId>12345</customerId>
        </tns:GetCustomerDetails>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Expected behaviour

As described, elements of body should correspond to message parts.

@veewee
Copy link
Member

veewee commented Jul 19, 2024

Thanks for testing out this package and reporting @MudrakIvan!

Your statement is right. I'll look into it soon.

@veewee
Copy link
Member

veewee commented Jul 19, 2024

Hello @MudrakIvan,

This seems to be true depending on some other parameters like binding-style.
It is a bit more complex than described above.

Could you play around with the changes in #16 to see if this works for you?

(there is still one thing I need to figure out - which should not impact this specific call you are trying to perform.)

Thanks again for the detailed information !

@MudrakIvan
Copy link
Author

Hello @veewee,

provided changes fixes are sufficient for operations that i'm working with.

Thanks for quick response!

@veewee
Copy link
Member

veewee commented Jul 20, 2024

@MudrakIvan Tagged the fix : https://github.com/php-soap/encoding/releases/tag/0.7.0

Feel free to let me know if there is anything else we can improve in this package :) It's rather new so there might be some bugs hiding here and there. I'm open for all feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants