Skip to content

Commit

Permalink
Changes to support the redefining of a namespace alias
Browse files Browse the repository at this point in the history
within different elements.  The provided WSDL was not serializing the response
correctly when returning the XML.
Created a request response folder to test the changes that were made and made sure
code coverage remained the same.
  • Loading branch information
lah8789 committed Jul 27, 2021
1 parent 03d1f78 commit cfb4497
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/wsdl/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,19 @@ export class MessageElement extends Element {
const ns = nsName.prefix;
let schema = definitions.schemas[definitions.xmlns[ns]];
this.element = schema.elements[nsName.name];
let schemaToLookup;
if (!this.element) {
// Try to find it another way
schemaToLookup = part.xmlns;
schema = definitions.schemas[schemaToLookup[Object.keys(schemaToLookup)[0]]];
this.element = schema.elements[nsName.name];
}
if (!this.element) {
debug(nsName.name + ' is not present in wsdl and cannot be processed correctly.');
return;
}
this.element.targetNSAlias = ns;
this.element.targetNamespace = definitions.xmlns[ns];
this.element.targetNamespace = (schemaToLookup && schemaToLookup.xsns) || definitions.xmlns[ns];

// set the optional $lookupType to be used within `client#_invoke()` when
// calling `wsdl#objectToDocumentXML()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<xsd:schema targetNamespace="http://example.com/bar/xsd" elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bar="http://example.com/bar/xsd"
xmlns:bar1="http://example.com/bar1/xsd">
<xsd:import schemaLocation="bar1.xsd" namespace="http://example.com/bar1/xsd"/>
<xsd:complexType name="Request1">
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element name="requestHeader" type="bar1:RequestHeader"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Request1" type="bar:Request1" />
<xsd:complexType name="Response1">
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element name="responseHeader" type="bar1:ResponseHeader"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Response1" type="bar:Response1"/>
</xsd:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<xsd:schema targetNamespace="http://example.com/bar1/xsd" elementFormDefault="qualified" version="2.1.4"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:bar1="http://example.com/bar1/xsd">
<xsd:simpleType name="UUID">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="RequestHeader">
<xsd:sequence>
<xsd:element name="requestId" type="bar1:UUID" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="RequestHeader" type="bar1:RequestHeader"/>
<xsd:complexType name="ResponseHeader">
<xsd:sequence>
<xsd:element name="requestId" type="bar1:UUID" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ResponseHeader" type="bar1:ResponseHeader"/>
<xsd:complexType name="ErrorInformation">
<xsd:sequence>
<xsd:element name="message" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ErrorInformation" type="bar1:ErrorInformation"/>
</xsd:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"requestHeader": {
"requestId": "79d9372c-d2fe-4f86-a637-d1f5710bb439"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://example.com/foo/wsdl" xmlns:xsns="http://example.com/bar1/xsd"><soap:Body><Request1><requestHeader><requestId>79d9372c-d2fe-4f86-a637-d1f5710bb439</requestId></requestHeader></Request1></soap:Body></soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope" xmlns:uba="http://example.com/bar1/xsd">
<soapenv:Header/>
<soapenv:Body>
<cus:Response1 xmlns:cus="http://example.com/bar/xsd">
<cus:responseHeader>
<uba:requestId>79d9372c-d2fe-4f86-a637-d1f5710bb439</uba:requestId>
</ns2:requestHeader>
</cus:Request1>
</soapenv:Body>
</soapenv:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="foo" targetNamespace="http://example.com/foo/wsdl"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ns0="http://example.com/foo/wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
<wsdl:types>
<xsd:schema>
<xsd:import namespace="http://example.com/bar/xsd" schemaLocation="bar.xsd"/>
<xsd:import namespace="http://example.com/bar1/xsd" schemaLocation="bar1.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ErrorInfo">
<wsdl:part xmlns:xsns="http://example.com/bar1/xsd" name="ErrorInfo" element="xsns:ErrorInformation">
</wsdl:part>
</wsdl:message>
<wsdl:message name="Request1">
<wsdl:part xmlns:xsns="http://example.com/bar/xsd" name="Request1" element="xsns:Request1">
</wsdl:part>
</wsdl:message>
<wsdl:message name="Response1">
<wsdl:part xmlns:xsns="http://example.com/bar/xsd" name="Response1" element="xsns:Response1">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="foo_PortType">
<wsdl:operation name="fooOp">
<wsdl:input name="Request1" message="ns0:Request1">
</wsdl:input>
<wsdl:output name="Response1" message="ns0:Response1">
</wsdl:output>
<wsdl:fault name="ErrorResponseType" message="ns0:ErrorInfo">
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="foo_Binding" type="ns0:foo_PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="fooOp">
<soap:operation style="document"/>
<wsdl:input name="Request1">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="Response1">
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="ErrorResponseType">
<soap:fault name="ErrorResponseType" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="foo">
<wsdl:port name="test_Port" binding="ns0:foo_Binding">
<soap:address location="http://localhost:8888/mockfoo_Binding"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

0 comments on commit cfb4497

Please sign in to comment.