-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Mediation Tool(SOAP -> REST)
#SOAP Endpoint URL:
http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso
#WSDL
http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL
#Operation that I am trying to access -
FullCountryInfo(http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?op=FullCountryInfo)
#XML Input
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.oorsprong.org/websamples.countryinfo">
<soapenv:Header/>
<soapenv:Body>
<web:FullCountryInfo>
<web:sCountryISOCode>IN</web:sCountryISOCode>
</web:FullCountryInfo>
</soapenv:Body>
</soapenv:Envelope>#XML Output
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<m:FullCountryInfoResponse xmlns:m="http://www.oorsprong.org/websamples.countryinfo">
<m:FullCountryInfoResult>
<m:sISOCode>IN</m:sISOCode>
<m:sName>India</m:sName>
<m:sCapitalCity>New Delhi</m:sCapitalCity>
<m:sPhoneCode>91</m:sPhoneCode>
<m:sContinentCode>AS</m:sContinentCode>
<m:sCurrencyISOCode>INR</m:sCurrencyISOCode>
<m:sCountryFlag>http://www.oorsprong.org/WebSamples.CountryInfo/Images/India.jpg</m:sCountryFlag>
<m:Languages>
<m:tLanguage>
<m:sISOCode>hin</m:sISOCode>
<m:sName>Hindi</m:sName>
</m:tLanguage>
</m:Languages>
</m:FullCountryInfoResult>
</m:FullCountryInfoResponse>
</soap:Body>
</soap:Envelope>Help Required
I am trying to access SOAP service the REST way using Loopback4, Can someone please tell me how do I write the service to receive multiple parameters as response ?
Eg: If i had only one parameter in response I could have written it something like this:
export interface CountryISOCode {
sCountryISOCode: string;
}Now I have Name, CapitalCity,Phone,PhoneCode,ContinentCode etc in the response, how do i capture all of them ?
Also, incase if I had multiple parameters to send, how do i send it ?
I cannot find any detailed documentation regarding the same, so can someone please guide me regarding the same.
##Below is my current code
#country.datasource.json
{
"name": "country",
"connector": "soap",
"url": "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso",
"wsdl": "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?wsdl",
"remotingEnabled": true,
"operations": {
"CountryName": {
"service": "CountryInfoService",
"port": "CountryInfoServiceSoap",
"operation": "CountryName"
},
"FullCountryInfo": {
"service": "CountryInfoService",
"port": "CountryInfoServiceSoap",
"operation": "FullCountryInfo"
}
}
}#country.service.ts
import {getService} from '@loopback/service-proxy';
import {inject, Provider} from '@loopback/core';
import {CountryDataSource} from '../datasources';
export interface CountryNameResponse {
result: {
value: string;
};
}
export interface FullCountryInfoResponse {
result: {
value: string;
};
}
export interface CountryISOCode {
sCountryISOCode: string;
}
export interface CountryService {
CountryName(args: CountryISOCode): Promise<CountryNameResponse>;
FullCountryInfo(args: CountryISOCode): Promise<FullCountryInfoResponse>;
}
export class CountryServiceProvider implements Provider<CountryService> {
constructor(
// country must match the name property in the datasource json file
@inject('datasources.country')
protected dataSource: CountryDataSource = new CountryDataSource(),
) {}
value(): Promise<CountryService> {
return getService(this.dataSource);
}
}#country.controller.ts
import {getService} from '@loopback/service-proxy';
import {inject, Provider} from '@loopback/core';
import {CountryDataSource} from '../datasources';
export interface CountryNameResponse {
result: {
value: string;
};
}
export interface FullCountryInfoResponse {
result: {
value: string;
};
}
export interface CountryISOCode {
sCountryISOCode: string;
}
export interface CountryService {
CountryName(args: CountryISOCode): Promise<CountryNameResponse>;
FullCountryInfo(args: CountryISOCode): Promise<FullCountryInfoResponse>;
}
export class CountryServiceProvider implements Provider<CountryService> {
constructor(
// country must match the name property in the datasource json file
@inject('datasources.country')
protected dataSource: CountryDataSource = new CountryDataSource(),
) {}
value(): Promise<CountryService> {
return getService(this.dataSource);
}
}Current Behavior
Expected Behavior
JSON & XML response with all the details containing:
Name, CapitalCity,Phone,PhoneCode,ContinentCode etc
