Skip to content

Commit

Permalink
Fixed checking for empty obj.Body before further actions
Browse files Browse the repository at this point in the history
  • Loading branch information
raviolin committed Feb 8, 2018
1 parent 905eadb commit 24736cd
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,18 @@ Client.prototype._invoke = function(method, args, location, callback, options, e
return callback(null, null, body, obj.Header, xml);
}

// If it's not HTML and Soap Body is empty
if (!obj.html && !obj.Body) {
return callback(null, obj, body, obj.Header);
}

if( typeof obj.Body !== 'object' ) {
var error = new Error('Cannot parse response');
error.response = response;
error.body = body;
return callback(error, obj, body, undefined, xml);
}

// if Soap Body is empty
if (!obj.Body) {
return callback(null, obj, body, obj.Header, xml);
}

result = obj.Body[output.$name];
// RPC/literal response body may contain elements with added suffixes I.E.
// 'Response', or 'Output', or 'Out'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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:ns1="http://ws.wso2.org/dataservice">
<soap:Header></soap:Header>
<soap:Body>
<ns0:getAppointmentNumber xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/XMLSchema-instance">
<ns0:id>353159</ns0:id>
</ns0:getAppointmentNumber>
</soap:Body>
</soap:Envelope>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"id": 353159
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"number": {
"number": "АИ020"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<number xmlns="http://www.w3.org/2001/XMLSchema-instance">
<number>АИ020</number>
</number>
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://ws.wso2.org/dataservice" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://www.w3.org/2001/XMLSchema-instance">
<wsdl:documentation>appointmentLocal</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/XMLSchema-instance">
<xs:element name="getAppointmentNumber">
<xs:complexType>
<xs:sequence>
<xs:element name="id" nillable="true" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="number" type="ns0:number"/>
<xs:complexType name="number">
<xs:sequence>
<xs:element minOccurs="0" name="number" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ws.wso2.org/dataservice">
<xs:element name="DataServiceFault">
<xs:complexType>
<xs:sequence>
<xs:element name="current_params" type="xs:string"/>
<xs:element name="current_request_name" type="xs:string"/>
<xs:element name="nested_exception" type="xs:string"/>
<xs:element name="source_data_service">
<xs:complexType>
<xs:sequence>
<xs:element name="location" type="xs:string"/>
<xs:element name="default_namespace" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="data_service_name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ds_code" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="REQUEST_STATUS" type="xs:string"/>
<xs:element name="DATA_SERVICE_RESPONSE">
<xs:complexType>
<xs:sequence>
<xs:any minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="DataServiceFault">
<wsdl:part name="parameters" element="ns1:DataServiceFault">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAppointmentNumberResponse">
<wsdl:part name="parameters" element="ns0:number">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getAppointmentNumberRequest">
<wsdl:part name="parameters" element="ns0:getAppointmentNumber">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="appointmentLocalPortType">
<wsdl:operation name="getAppointmentNumber">
<wsdl:documentation/>
<wsdl:input message="ns0:getAppointmentNumberRequest" wsaw:Action="urn:getAppointmentNumber">
</wsdl:input>
<wsdl:output message="ns0:getAppointmentNumberResponse" wsaw:Action="urn:getAppointmentNumberResponse">
</wsdl:output>
<wsdl:fault name="DataServiceFault" message="ns0:DataServiceFault" wsaw:Action="urn:getAppointmentNumberDataServiceFault">
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="appointmentLocalSOAP12Binding" type="ns0:appointmentLocalPortType">
<soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getAppointmentNumber">
<soap12:operation soapAction="urn:getAppointmentNumber" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="DataServiceFault">
<soap12:fault name="DataServiceFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="appointmentLocalSOAP11Binding" type="ns0:appointmentLocalPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getAppointmentNumber">
<soap:operation soapAction="urn:getAppointmentNumber" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="DataServiceFault">
<soap:fault name="DataServiceFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="appointmentLocalHttpBinding" type="ns0:appointmentLocalPortType">
<http:binding verb="POST"/>
<wsdl:operation name="getAppointmentNumber">
<http:operation location="getAppointmentNumber"/>
<wsdl:input>
<mime:content part="parameters" type="text/xml"/>
</wsdl:input>
<wsdl:output>
<mime:content part="parameters" type="text/xml"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="appointmentLocal">
<wsdl:port name="SecureSOAP11Endpoint" binding="ns0:appointmentLocalSOAP11Binding">
<soap:address location="http://localhost:8080/"/>
</wsdl:port>
<wsdl:port name="SecureHTTPEndpoint" binding="ns0:appointmentLocalHttpBinding">
<http:address location="http://localhost:8080/"/>
</wsdl:port>
<wsdl:port name="SOAP11Endpoint" binding="ns0:appointmentLocalSOAP11Binding">
<soap:address location="http://localhost:8080/"/>
</wsdl:port>
<wsdl:port name="SecureSOAP12Endpoint" binding="ns0:appointmentLocalSOAP12Binding">
<soap12:address location="http://localhost:8080/"/>
</wsdl:port>
<wsdl:port name="HTTPEndpoint" binding="ns0:appointmentLocalHttpBinding">
<http:address location="http://localhost:8080/"/>
</wsdl:port>
<wsdl:port name="SOAP12Endpoint" binding="ns0:appointmentLocalSOAP12Binding">
<soap12:address location="http://localhost:8080/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

0 comments on commit 24736cd

Please sign in to comment.