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

duplicate element definitions #48

Open
mohs8421 opened this issue Nov 6, 2018 · 4 comments
Open

duplicate element definitions #48

mohs8421 opened this issue Nov 6, 2018 · 4 comments

Comments

@mohs8421
Copy link

mohs8421 commented Nov 6, 2018

I am currently investigating, whether I can replace the outdated nusoap library with yours.
However I find one thing alarming in my test implementation.
The application is rather large, so there are many functions available to soap, some have the same parameter names.
The generated wsdl looks like this:
<xsd:element name="login" type="xsd:string"/> <xsd:element name="password" type="xsd:string"/> <xsd:element name="login" type="xsd:string"/> <xsd:element name="password" type="xsd:string"/>
So I have elements defined multiple times, hopefully all of them with the same type, so it might not cause a real problem. But it might also mean, that I cannot use this library for my purpose.
Wouldn't it be better to not define simple types on a global level?

@piotrooo
Copy link
Owner

piotrooo commented Nov 8, 2018

What do you mean "global level"?

@mohs8421
Copy link
Author

mohs8421 commented Nov 8, 2018

these elements are defined in types, where I would expect complex types to be defined, not elements of complex types

@piotrooo
Copy link
Owner

piotrooo commented Nov 9, 2018

Could you provide some example, how are you generate the code.
Please give a code how you generate a XML. Current output and expected output.

@mohs8421
Copy link
Author

mohs8421 commented Nov 13, 2018

Current output is something like this:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Product namesService" targetNamespace="http://redacted.com/wsdl/" xmlns:tns="http://redacted.com/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://redacted.com/wsdl/"><script xmlns="" id="custom-useragent-string"/>
  <types>
    <xsd:schema targetNamespace="http://redacted.com/wsdl/" xmlns="http://redacted.com/wsdl/">
      <xsd:element name="login" type="xsd:string"/>
      <xsd:element name="password" type="xsd:string"/>
      <xsd:element name="start_transactionResponse" type="xsd:string"/>
      <xsd:element name="end_transactionResponse" type="xsd:boolean"/>
      <xsd:element name="login" type="xsd:string"/>
      <xsd:element name="password" type="xsd:string"/>
      <xsd:element name="filter_arr" type="ns:Filter_arr"/>
      <xsd:complexType name="Filter_arr">
        <xsd:sequence>
          <xsd:element name="column" type="xsd:string"/>
          <xsd:element name="value" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:element name="filter_arr" type="ns:Filter_arr"/>
      <xsd:complexType name="Filter_arr">
        <xsd:sequence>
          <xsd:element name="column" type="xsd:string"/>
          <xsd:element name="value" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:element name="filter_arr" type="ns:Filter_arr"/>
      <xsd:complexType name="Filter_arr">
        <xsd:sequence>
          <xsd:element name="column" type="xsd:string"/>
          <xsd:element name="value" type="xsd:string"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:element name="name" type="xsd:string"/>
    </xsd:schema>
  </types>
  <message name="start_transactionRequest">
    <part name="login" element="ns:login"/>
    <part name="password" element="ns:password"/>
  </message>
  <message name="start_transactionResponse">
    <part name="start_transactionResponse" element="ns:start_transactionResponse"/>
  </message>
  <message name="end_transactionRequest"/>
  <message name="end_transactionResponse">
    <part name="end_transactionResponse" element="ns:end_transactionResponse"/>
  </message>
  <message name="start_license_transactionRequest">
    <part name="login" element="ns:login"/>
    <part name="password" element="ns:password"/>
  </message>
  <message name="start_license_transactionResponse">
    <part name="start_license_transactionResponse" element="ns:start_license_transactionResponse"/>
  </message>
  <message name="get_usersRequest">
    <part name="filter_arr" element="ns:filter_arr"/>
  </message>
  <message name="get_usersResponse">
    <part name="get_usersResponse" element="ns:get_usersResponse"/>
  </message>
  <portType name="Product namesServicePortType">
    <operation name="start_transaction">
      <input message="tns:start_transactionRequest"/>
      <output message="tns:start_transactionResponse"/>
    </operation>
    <operation name="end_transaction">
      <input message="tns:end_transactionRequest"/>
      <output message="tns:end_transactionResponse"/>
    </operation>
    <operation name="get_users">
      <input message="tns:get_usersRequest"/>
      <output message="tns:get_usersResponse"/>
    </operation>
  </portType>
  <binding name="Product namesServiceBinding" type="tns:Product namesServicePortType">
    <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="start_transaction">
      <soap12:operation soapAction="http://redacted.com/wsdl//#start_transaction"/>
      <input>
        <soap12:body use="literal" namespace="http://redacted.com/wsdl/"/>
      </input>
      <output>
        <soap12:body use="literal" namespace="http://redacted.com/wsdl/"/>
      </output>
    </operation>
    <operation name="end_transaction">
      <soap12:operation soapAction="http://redacted.com/wsdl//#end_transaction"/>
      <input>
        <soap12:body use="literal" namespace="http://redacted.com/wsdl/"/>
      </input>
      <output>
        <soap12:body use="literal" namespace="http://redacted.com/wsdl/"/>
      </output>
    </operation>
    <operation name="get_users">
      <soap12:operation soapAction="http://redacted.com/wsdl//#get_users"/>
      <input>
        <soap12:body use="literal" namespace="http://redacted.com/wsdl/"/>
      </input>
      <output>
        <soap12:body use="literal" namespace="http://redacted.com/wsdl/"/>
      </output>
    </operation>
  </binding>
  <service name="Product namesServiceService">
    <port name="Product namesServicePort" binding="tns:Product namesServiceBinding">
      <soap12:address location="redacted/index.php"/>
    </port>
  </service>
</definitions>

I removed a lot of duplicates and unimportant details for you, just imagine, that this filter_arr example is used by many operations provided, the same goes for the simple element "login"
The code that generates this is translating from the old library I used to yours.
Essentially I create Node elements directly to circumvent going through the parsing process once more.
These are then passed to the parameters and they are passed to the methods, just as the constructor of Method defines.
Example for the "Filter_arr" parts, it looks like this:

$elements[] = new Node('string', 'column', false);
$elements[] = new Node('string', 'value', false);
…
$parameter = new Parameter(new Node($parameter_type, $parameter_name, $is_array, $elements));
// imagine $out_parameter being constructed the same way
$method = new Method($function, $parameters, $out_parameter);
$wsdl_builder->setMethod($method);

What I would expect is not having simple string message parts defined as their own elements, and not to have duplicate definitions.

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

No branches or pull requests

2 participants