Skip to content

Commit

Permalink
Merge pull request #29 from indika-dev/main
Browse files Browse the repository at this point in the history
fix for issue 28
  • Loading branch information
rosensilva authored Oct 31, 2024
2 parents 2ab7e12 + b30b083 commit 8326ae9
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,11 @@ private static Document createSOAPRequestXMLForOperation(ArrayList<String> param
path = path.concat(escapeFreeMarkerTemplate(parameterTreeNodes[j])).concat(".");
}
element.setAttribute(IS_EMPTY_ATTRIBUTE, "true");
element.setAttribute(VALUE_ATTRIBUTE, path.substring(0, path.length() - 1));
if (path.length() == 0) {
element.setAttribute(VALUE_ATTRIBUTE, "");
} else {
element.setAttribute(VALUE_ATTRIBUTE, path.substring(0, path.length() - 1));
}
}
if (prevElement != null) {
prevElement.appendChild(element);
Expand Down
16 changes: 15 additions & 1 deletion src/test/java/org/wso2/soaptorest/SOAPToRESTConverterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,18 @@ void testURLGetSOAPtoRESTConversionData() throws MalformedURLException, SOAPToRE

}

}
@Test
void testIssue28() throws MalformedURLException, SOAPToRESTException {

URL url = new URL(
"https://raw.githubusercontent.com/indika-dev/soap-to-rest/main/src/test/resources/issue-28/failing.wsdl");
SOAPtoRESTConversionData soaPtoRESTConversionData =
SOAPToRESTConverter.getSOAPtoRESTConversionData(url, "Test API", "1.0.0");
assertTrue(StringUtils.isNotBlank(soaPtoRESTConversionData.getOASString()));
assertEquals(1, soaPtoRESTConversionData.getAllSOAPRequestBodies().size());
assertEquals(soaPtoRESTConversionData.getSoapService(), "myServer");
assertEquals(soaPtoRESTConversionData.getSoapPort(), "myServerSOAP");

}

}
92 changes: 92 additions & 0 deletions src/test/resources/issue-28/failing.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<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>

0 comments on commit 8326ae9

Please sign in to comment.