Code Monkey home page Code Monkey logo

soap-to-rest's Introduction

SOAP to REST Conversion Java Library

Introduction

This open source library is capable of converting SOAP backend service to REST backends. The library is written to get the SOAP Webservice contract using WSDL file and generate OpenAPI Specification (Swagger file) along with the required SOAP Request bodies that will convert the REST JSON input to SOAP message. There are two methods to convert the SOAP Endpoints. Either using the URL of the real SOAP backend or the Zip file contain all the WSDL files and respective XSD files.

How to build

Clone the repository and build the project using executing following command in terminal

mvn clean install

Prerequisites

  • Maven 3.6.3 or higher (tested on 3.6.3)
  • Java 11.0 or higher (tested on java 11)

How to use

There are two methods in SOAPToRestConverter.java that convert the WSDL to REST Endpoint

  1. Use the following method to generate REST service from WSDL URL
getSOAPtoRESTConversionData(URL url,String apiTitle,String apiVersion)
  1. Use the following method to generate REST service from WSDL File
getSOAPtoRESTConversionData(String filePath,String apiTitle,String apiVersion)

Both methods will return an object from SOAPtoRESTConversionData.java class which contains following

OpenAPI openAPI;
        Map<String, SOAPRequestElement> soapRequestBodyMapping;
        String soapService;
        String soapPort;
  • openAPI, soapService and soapPort are the respective representation of the SOAP endpoint
  • soapRequestBodyMapping contains a map of SOAPRequestElement for all the SOAP operations.

SOAPRequestElement Contains following,

Document soapRequestBody;
        String soapAction;
        String soapNamespace;
        String nameSpace;

Document contains org.w3c.dom.Document of the Request message that need to send to the SOAP backend under soapAction. This Document contains the message with the placeholders for JSON input

Run in Command-line

Build the JAR with command mvn package. Then you can generate a YAML output for any WSDL file like this:

java -jar target/soaptorest-1.6-jar-with-dependencies.jar src/test/resources/complex/nested.wsdl MyNestedRestAPI 1.6.2

After the jar file in the command, the 1st parameter (required) is the path to the WSDL file. The 2nd parameter is the REST API title (default WSDL file name), and the 3rd is the version number (default "1.0.0").

License

Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

WSO2 Inc. licenses this file to you under the Apache License,
Version 2.0 (the "License"); you may not use this file except
in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

soap-to-rest's People

Contributors

rosensilva avatar gdlmadushanka avatar sanojpunchihewa avatar mcgitty avatar maheshika avatar madushadhanushka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.