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

WSDL not parseable #28

Open
indika-dev opened this issue Aug 23, 2024 · 0 comments · May be fixed by #29
Open

WSDL not parseable #28

indika-dev opened this issue Aug 23, 2024 · 0 comments · May be fixed by #29
Labels

Comments

@indika-dev
Copy link

indika-dev commented Aug 23, 2024

Description:
I want to transform a specific WSDL to OpenAPI by using this library. In general, it simply works, but in one case, the WSDL file is not parsed. SoapUI is reading the WSDL file without problems.

Suggested Labels:

Suggested Assignees:

Affected Product Version:
soap-to-rest v1.7

OS, DB, other environment details and versions:
Ubuntu 22.04, OracleJDK 17.0.12

Steps to reproduce:
Try to convert this example WSDL:

buggy WSDL
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:ServerWsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="myServer"
targetNamespace="urn:ServerWsdl">
<wsdl:types>
  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:ServerWsdl">
    <xsd:complexType name="getRequestType">
      <xsd:sequence>
        <xsd:element name="header" type="tns:standardheaderType" />
        <xsd:element name="body" type="tns:getRequestBodyType" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="getResultType">
      <xsd:sequence>
        <xsd:element name="result" type="tns:resultType" maxOccurs="1" minOccurs="0" />
        <xsd:element name="error" type="tns:errorType" maxOccurs="1" minOccurs="0" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="standardheaderType">
      <xsd:sequence>
        <xsd:element name="applicationversionnr" type="xsd:string" maxOccurs="1" minOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="getRequestBodyType">
      <xsd:sequence>
        <xsd:element name="transactioncode" type="xsd:string" maxOccurs="1" minOccurs="1" />
        <xsd:element name="languageisocode" type="xsd:string" maxOccurs="1" minOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="disclosureinformationType">
      <xsd:sequence>
        <xsd:element name="companyname" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element
          name="street" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element
          name="countryisocode" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element
          name="city" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element name="postcode"
          type="xsd:string" maxOccurs="1" minOccurs="0" /> 
</xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="clientinformationType">
      <xsd:sequence>
        <xsd:element name="fieldname" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element name="fieldvalue" type="xsd:string" maxOccurs="1" minOccurs="0" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="resultType">
      <xsd:sequence>
        <xsd:element name="transactioncode" type="xsd:string" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="errorType">
      <xsd:sequence>
        <xsd:element name="errorcode" type="xsd:string" />
        <xsd:element name="errortext" type="xsd:string" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:schema>
</wsdl:types>
<wsdl:message name="getRequest">
  <wsdl:part name="getRequest" type="tns:getRequestType" />
</wsdl:message>
<wsdl:message name="getResponse">
  <wsdl:part name="getResponse" type="tns:getResultType" />
</wsdl:message>
<wsdl:portType name="myServer">
  <wsdl:operation name="get">
    <wsdl:input message="tns:getRequest" />
    <wsdl:output message="tns:getResponse" />
  </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="myServerSOAP" type="tns:myServer">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="get">
    <soap:operation soapAction="urn:ServerWsdl/get" />
    <wsdl:input>
      <soap:body namespace="urn:ServerWsdl" use="literal" />
    </wsdl:input>
    <wsdl:output>
      <soap:body namespace="urn:ServerWsdl" use="literal" />
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>
<wsdl:service name="myServer">
  <wsdl:port binding="tns:myServerSOAP" name="myServerSOAP">
    <soap:address
      location="https://some.server.de/myServer.php" />
  </wsdl:port>
</wsdl:service>
</wsdl:definitions>

I then get the following exception:

java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 0
at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4608)
at java.base/java.lang.String.substring(String.java:2711)
at > org.wso2.soaptorest.SOAPRequestBodyGenerator.createSOAPRequestXMLForOperation(SOAPRequestBodyGenerator.java:355)
at > org.wso2.soaptorest.SOAPRequestBodyGenerator.generateSOAPtoRESTConversionObjectFromOAS(SOAPRequestBodyGenerat> or.java:150)
at org.wso2.soaptorest.SOAPToRESTConverter.getSOAPtoRESTConversionData(SOAPToRESTConverter.java:51)

I took a deeper look at the buggy WSDL and I finally got a WSDL which is perfectly working:

working WSDL
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="urn:ServerWsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="myServer"
targetNamespace="urn:ServerWsdl">
<wsdl:types>
  <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:ServerWsdl">
    <xsd:complexType name="getRequestType">
      <xsd:sequence>
        <xsd:element name="header" type="tns:standardheaderType" />
        <xsd:element name="body" type="tns:getRequestBodyType" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="getResultType">
      <xsd:sequence>
        <xsd:element name="result" type="tns:resultType" maxOccurs="1" minOccurs="0" />
        <xsd:element name="error" type="tns:errorType" maxOccurs="1" minOccurs="0" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="standardheaderType">
      <xsd:sequence>
        <xsd:element name="applicationversionnr" type="xsd:string" maxOccurs="1" minOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="getRequestBodyType">
      <xsd:sequence>
        <xsd:element name="transactioncode" type="xsd:string" maxOccurs="1" minOccurs="1" />
        <xsd:element name="languageisocode" type="xsd:string" maxOccurs="1" minOccurs="1" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="disclosureinformationType">
      <xsd:sequence>
        <xsd:element name="companyname" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element
          name="street" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element
          name="countryisocode" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element
          name="city" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element name="postcode"
          type="xsd:string" maxOccurs="1" minOccurs="0" />
</xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="clientinformationType">
      <xsd:sequence>
        <xsd:element name="fieldname" type="xsd:string" maxOccurs="1" minOccurs="0" />
        <xsd:element name="fieldvalue" type="xsd:string" maxOccurs="1" minOccurs="0" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="resultType">
      <xsd:sequence>
        <xsd:element name="transactioncode" type="xsd:string" />
      </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="errorType">
      <xsd:sequence>
        <xsd:element name="errorcode" type="xsd:string" />
        <xsd:element name="errortext" type="xsd:string" />
      </xsd:sequence>
    </xsd:complexType>
  </xsd:schema>
</wsdl:types>
<wsdl:message name="getRequest">
  <wsdl:part name="getRequest" type="tns:getRequestType" />
</wsdl:message>
<wsdl:message name="getResponse">
  <wsdl:part name="getResponse" type="tns:getResultType" />
</wsdl:message>
<wsdl:portType name="myServer">
  <wsdl:operation name="get">
    <wsdl:input message="tns:getRequest" />
    <wsdl:output message="tns:getResponse" />
  </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="myServerBinding" type="tns:myServerWsdl">
  <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
  <wsdl:operation name="get">
    <soap:operation soapAction="urn:ServerWsdl/get" />
    <wsdl:input>
      <soap:body namespace="urn:ServerWsdl" use="literal" />
    </wsdl:input>
    <wsdl:output>
      <soap:body namespace="urn:ServerWsdl" use="literal" />
    </wsdl:output>
  </wsdl:operation>
</wsdl:binding>
<wsdl:service name="myServer">
  <wsdl:port binding="tns:myServerBinding" name="myServerSOAP">
    <soap:address
      location="https://some.server.de/myServer.php" />
  </wsdl:port>
</wsdl:service>
</wsdl:definitions>
The difference is, that I changed in wsdl:service -> wsdl:port binding to "tns:myServerBinding" and wsdl:binding is now ```xml ``` Because the original WSDL is parsed by SoapUI, it might be a bug in this library. Could you please have a look at it?

Related Issues:

@indika-dev indika-dev linked a pull request Aug 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants