From 7c4016e056a3e4fcb31483f2ba406e32808e4db7 Mon Sep 17 00:00:00 2001 From: lor6 Date: Sun, 25 Jun 2017 12:58:09 +0300 Subject: [PATCH] webservices examples (#2134) * webservices examples * update to angular 4 --- .../WebContent/META-INF/MANIFEST.MF | 3 + guest/webservices/rest-client/pom.xml | 27 ++++ .../rest-client/rest-client/.angular-cli.json | 57 ++++++++ .../rest-client/rest-client/.editorconfig | 13 ++ .../rest-client/rest-client/.gitignore | 42 ++++++ .../rest-client/rest-client/README.md | 28 ++++ .../rest-client/e2e/app.e2e-spec.ts | 14 ++ .../rest-client/rest-client/e2e/app.po.ts | 11 ++ .../rest-client/e2e/tsconfig.e2e.json | 12 ++ .../rest-client/rest-client/karma.conf.js | 33 +++++ .../rest-client/rest-client/package.json | 48 +++++++ .../rest-client/protractor.conf.js | 28 ++++ .../rest-client/src/app/app.component.css | 0 .../rest-client/src/app/app.component.html | 13 ++ .../rest-client/src/app/app.component.spec.ts | 32 +++++ .../rest-client/src/app/app.component.ts | 10 ++ .../rest-client/src/app/app.module.ts | 25 ++++ .../rest-client/src/app/app.service.ts | 36 +++++ .../rest-client/src/app/users.component.html | 15 ++ .../rest-client/src/app/users.component.ts | 39 +++++ .../rest-client/src/assets/.gitkeep | 0 .../src/environments/environment.prod.ts | 3 + .../src/environments/environment.ts | 8 ++ .../rest-client/rest-client/src/favicon.ico | Bin 0 -> 5430 bytes .../rest-client/rest-client/src/index.html | 14 ++ .../rest-client/rest-client/src/main.ts | 11 ++ .../rest-client/rest-client/src/polyfills.ts | 73 ++++++++++ .../rest-client/rest-client/src/styles.css | 1 + .../rest-client/rest-client/src/test.ts | 32 +++++ .../rest-client/src/tsconfig.app.json | 13 ++ .../rest-client/src/tsconfig.spec.json | 20 +++ .../rest-client/rest-client/src/typings.d.ts | 5 + .../rest-client/rest-client/tsconfig.json | 20 +++ .../rest-client/rest-client/tslint.json | 135 ++++++++++++++++++ .../WebContent/META-INF/MANIFEST.MF | 3 + .../rest-server/WebContent/WEB-INF/web.xml | 20 +++ guest/webservices/rest-server/pom.xml | 51 +++++++ .../com/stackify/ApplicationInitializer.java | 9 ++ .../main/java/com/stackify/models/User.java | 43 ++++++ .../com/stackify/services/CorsFilter.java | 19 +++ .../com/stackify/services/UserService.java | 33 +++++ .../stackify/services/UserServiceTest.java | 34 +++++ .../main/java/com/stackify/JAXWSClient.java | 19 +++ .../services/DefaultUserImplService.java | 94 ++++++++++++ .../com/stackify/services/ObjectFactory.java | 48 +++++++ .../main/java/com/stackify/services/User.java | 87 +++++++++++ .../com/stackify/services/UserService.java | 47 ++++++ .../java/com/stackify/services/Users.java | 69 +++++++++ .../com/stackify/services/package-info.java | 2 + .../java/com/stackify/ServicePublisher.java | 11 ++ .../main/java/com/stackify/models/User.java | 32 +++++ .../main/java/com/stackify/models/Users.java | 16 +++ .../stackify/services/DefaultUserImpl.java | 27 ++++ .../com/stackify/services/UserService.java | 19 +++ .../WebContent/META-INF/MANIFEST.MF | 3 + guest/webservices/spring-rest-service/pom.xml | 48 +++++++ .../main/java/com/stackify/Application.java | 12 ++ .../com/stackify/config/SwaggerConfig.java | 22 +++ .../stackify/controllers/UserController.java | 52 +++++++ .../main/java/com/stackify/models/User.java | 34 +++++ 60 files changed, 1675 insertions(+) create mode 100644 guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF create mode 100644 guest/webservices/rest-client/pom.xml create mode 100644 guest/webservices/rest-client/rest-client/.angular-cli.json create mode 100644 guest/webservices/rest-client/rest-client/.editorconfig create mode 100644 guest/webservices/rest-client/rest-client/.gitignore create mode 100644 guest/webservices/rest-client/rest-client/README.md create mode 100644 guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts create mode 100644 guest/webservices/rest-client/rest-client/e2e/app.po.ts create mode 100644 guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json create mode 100644 guest/webservices/rest-client/rest-client/karma.conf.js create mode 100644 guest/webservices/rest-client/rest-client/package.json create mode 100644 guest/webservices/rest-client/rest-client/protractor.conf.js create mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.css create mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.html create mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts create mode 100644 guest/webservices/rest-client/rest-client/src/app/app.component.ts create mode 100644 guest/webservices/rest-client/rest-client/src/app/app.module.ts create mode 100644 guest/webservices/rest-client/rest-client/src/app/app.service.ts create mode 100644 guest/webservices/rest-client/rest-client/src/app/users.component.html create mode 100644 guest/webservices/rest-client/rest-client/src/app/users.component.ts create mode 100644 guest/webservices/rest-client/rest-client/src/assets/.gitkeep create mode 100644 guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts create mode 100644 guest/webservices/rest-client/rest-client/src/environments/environment.ts create mode 100644 guest/webservices/rest-client/rest-client/src/favicon.ico create mode 100644 guest/webservices/rest-client/rest-client/src/index.html create mode 100644 guest/webservices/rest-client/rest-client/src/main.ts create mode 100644 guest/webservices/rest-client/rest-client/src/polyfills.ts create mode 100644 guest/webservices/rest-client/rest-client/src/styles.css create mode 100644 guest/webservices/rest-client/rest-client/src/test.ts create mode 100644 guest/webservices/rest-client/rest-client/src/tsconfig.app.json create mode 100644 guest/webservices/rest-client/rest-client/src/tsconfig.spec.json create mode 100644 guest/webservices/rest-client/rest-client/src/typings.d.ts create mode 100644 guest/webservices/rest-client/rest-client/tsconfig.json create mode 100644 guest/webservices/rest-client/rest-client/tslint.json create mode 100644 guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF create mode 100644 guest/webservices/rest-server/WebContent/WEB-INF/web.xml create mode 100644 guest/webservices/rest-server/pom.xml create mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java create mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/models/User.java create mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java create mode 100644 guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java create mode 100644 guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceTest.java create mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java create mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java create mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java create mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/User.java create mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java create mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java create mode 100644 guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java create mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java create mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/models/User.java create mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java create mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java create mode 100644 guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java create mode 100644 guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF create mode 100644 guest/webservices/spring-rest-service/pom.xml create mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java create mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java create mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java create mode 100644 guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java diff --git a/guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF b/guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..254272e1c0 --- /dev/null +++ b/guest/webservices/rest-client/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/guest/webservices/rest-client/pom.xml b/guest/webservices/rest-client/pom.xml new file mode 100644 index 0000000000..af03ac1948 --- /dev/null +++ b/guest/webservices/rest-client/pom.xml @@ -0,0 +1,27 @@ + + 4.0.0 + com.stackify + rest-client + 0.0.1-SNAPSHOT + war + + + + maven-compiler-plugin + 3.5 + + 1.8 + 1.8 + + + + maven-war-plugin + 2.6 + + WebContent + false + + + + + \ No newline at end of file diff --git a/guest/webservices/rest-client/rest-client/.angular-cli.json b/guest/webservices/rest-client/rest-client/.angular-cli.json new file mode 100644 index 0000000000..5d1839d374 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/.angular-cli.json @@ -0,0 +1,57 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "project": { + "name": "rest-client" + }, + "apps": [ + { + "root": "src", + "outDir": "dist", + "assets": [ + "assets", + "favicon.ico" + ], + "index": "index.html", + "main": "main.ts", + "polyfills": "polyfills.ts", + "test": "test.ts", + "tsconfig": "tsconfig.app.json", + "testTsconfig": "tsconfig.spec.json", + "prefix": "app", + "styles": [ + "styles.css" + ], + "scripts": [], + "environmentSource": "environments/environment.ts", + "environments": { + "dev": "environments/environment.ts", + "prod": "environments/environment.prod.ts" + } + } + ], + "e2e": { + "protractor": { + "config": "./protractor.conf.js" + } + }, + "lint": [ + { + "project": "src/tsconfig.app.json" + }, + { + "project": "src/tsconfig.spec.json" + }, + { + "project": "e2e/tsconfig.e2e.json" + } + ], + "test": { + "karma": { + "config": "./karma.conf.js" + } + }, + "defaults": { + "styleExt": "css", + "component": {} + } +} diff --git a/guest/webservices/rest-client/rest-client/.editorconfig b/guest/webservices/rest-client/rest-client/.editorconfig new file mode 100644 index 0000000000..6e87a003da --- /dev/null +++ b/guest/webservices/rest-client/rest-client/.editorconfig @@ -0,0 +1,13 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +max_line_length = off +trim_trailing_whitespace = false diff --git a/guest/webservices/rest-client/rest-client/.gitignore b/guest/webservices/rest-client/rest-client/.gitignore new file mode 100644 index 0000000000..54bfd2001e --- /dev/null +++ b/guest/webservices/rest-client/rest-client/.gitignore @@ -0,0 +1,42 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. + +# compiled output +/dist +/tmp +/out-tsc + +# dependencies +/node_modules + +# IDEs and editors +/.idea +.project +.classpath +.c9/ +*.launch +.settings/ +*.sublime-workspace + +# IDE - VSCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +# misc +/.sass-cache +/connect.lock +/coverage +/libpeerconnection.log +npm-debug.log +testem.log +/typings + +# e2e +/e2e/*.js +/e2e/*.map + +# System Files +.DS_Store +Thumbs.db diff --git a/guest/webservices/rest-client/rest-client/README.md b/guest/webservices/rest-client/rest-client/README.md new file mode 100644 index 0000000000..b33d171f3c --- /dev/null +++ b/guest/webservices/rest-client/rest-client/README.md @@ -0,0 +1,28 @@ +# RestClient + +This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.1.3. + +## Development server + +Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. + +## Code scaffolding + +Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|module`. + +## Build + +Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build. + +## Running unit tests + +Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). + +## Running end-to-end tests + +Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). +Before running the tests make sure you are serving the app via `ng serve`. + +## Further help + +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). diff --git a/guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts b/guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts new file mode 100644 index 0000000000..2eb6dade08 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/e2e/app.e2e-spec.ts @@ -0,0 +1,14 @@ +import { RestClientPage } from './app.po'; + +describe('rest-client App', () => { + let page: RestClientPage; + + beforeEach(() => { + page = new RestClientPage(); + }); + + it('should display welcome message', () => { + page.navigateTo(); + expect(page.getParagraphText()).toEqual('Welcome to app!!'); + }); +}); diff --git a/guest/webservices/rest-client/rest-client/e2e/app.po.ts b/guest/webservices/rest-client/rest-client/e2e/app.po.ts new file mode 100644 index 0000000000..1e111a7ff6 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/e2e/app.po.ts @@ -0,0 +1,11 @@ +import { browser, by, element } from 'protractor'; + +export class RestClientPage { + navigateTo() { + return browser.get('/'); + } + + getParagraphText() { + return element(by.css('app-root h1')).getText(); + } +} diff --git a/guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json b/guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json new file mode 100644 index 0000000000..e2a9a2fc77 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/e2e/tsconfig.e2e.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/e2e", + "module": "commonjs", + "target": "es5", + "types": [ + "jasmine", + "node" + ] + } +} diff --git a/guest/webservices/rest-client/rest-client/karma.conf.js b/guest/webservices/rest-client/rest-client/karma.conf.js new file mode 100644 index 0000000000..4d9ab9d948 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/karma.conf.js @@ -0,0 +1,33 @@ +// Karma configuration file, see link for more information +// https://karma-runner.github.io/0.13/config/configuration-file.html + +module.exports = function (config) { + config.set({ + basePath: '', + frameworks: ['jasmine', '@angular/cli'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), + require('karma-coverage-istanbul-reporter'), + require('@angular/cli/plugins/karma') + ], + client:{ + clearContext: false // leave Jasmine Spec Runner output visible in browser + }, + coverageIstanbulReporter: { + reports: [ 'html', 'lcovonly' ], + fixWebpackSourcePaths: true + }, + angularCli: { + environment: 'dev' + }, + reporters: ['progress', 'kjhtml'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }); +}; diff --git a/guest/webservices/rest-client/rest-client/package.json b/guest/webservices/rest-client/rest-client/package.json new file mode 100644 index 0000000000..b10090830c --- /dev/null +++ b/guest/webservices/rest-client/rest-client/package.json @@ -0,0 +1,48 @@ +{ + "name": "rest-client", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@angular/animations": "^4.0.0", + "@angular/common": "^4.0.0", + "@angular/compiler": "^4.0.0", + "@angular/core": "^4.0.0", + "@angular/forms": "^4.0.0", + "@angular/http": "^4.0.0", + "@angular/platform-browser": "^4.0.0", + "@angular/platform-browser-dynamic": "^4.0.0", + "@angular/router": "^4.0.0", + "core-js": "^2.4.1", + "rxjs": "^5.1.0", + "zone.js": "^0.8.4" + }, + "devDependencies": { + "@angular/cli": "1.1.3", + "@angular/compiler-cli": "^4.0.0", + "@angular/language-service": "^4.0.0", + "@types/jasmine": "2.5.45", + "@types/node": "~6.0.60", + "codelyzer": "~3.0.1", + "jasmine-core": "~2.6.2", + "jasmine-spec-reporter": "~4.1.0", + "karma": "~1.7.0", + "karma-chrome-launcher": "~2.1.1", + "karma-cli": "~1.0.1", + "karma-coverage-istanbul-reporter": "^1.2.1", + "karma-jasmine": "~1.1.0", + "karma-jasmine-html-reporter": "^0.2.2", + "protractor": "~5.1.2", + "ts-node": "~3.0.4", + "tslint": "~5.3.2", + "typescript": "~2.3.3" + } +} diff --git a/guest/webservices/rest-client/rest-client/protractor.conf.js b/guest/webservices/rest-client/rest-client/protractor.conf.js new file mode 100644 index 0000000000..7ee3b5ee86 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/protractor.conf.js @@ -0,0 +1,28 @@ +// Protractor configuration file, see link for more information +// https://github.com/angular/protractor/blob/master/lib/config.ts + +const { SpecReporter } = require('jasmine-spec-reporter'); + +exports.config = { + allScriptsTimeout: 11000, + specs: [ + './e2e/**/*.e2e-spec.ts' + ], + capabilities: { + 'browserName': 'chrome' + }, + directConnect: true, + baseUrl: 'http://localhost:4200/', + framework: 'jasmine', + jasmineNodeOpts: { + showColors: true, + defaultTimeoutInterval: 30000, + print: function() {} + }, + onPrepare() { + require('ts-node').register({ + project: 'e2e/tsconfig.e2e.json' + }); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); + } +}; diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.css b/guest/webservices/rest-client/rest-client/src/app/app.component.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.html b/guest/webservices/rest-client/rest-client/src/app/app.component.html new file mode 100644 index 0000000000..94dc25088b --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/app/app.component.html @@ -0,0 +1,13 @@ + + + + Angular QuickStart + + + + + + + loading users component + + \ No newline at end of file diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts b/guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts new file mode 100644 index 0000000000..7d2799ceb6 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/app/app.component.spec.ts @@ -0,0 +1,32 @@ +import { TestBed, async } from '@angular/core/testing'; + +import { AppComponent } from './app.component'; + +describe('AppComponent', () => { + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ + AppComponent + ], + }).compileComponents(); + })); + + it('should create the app', async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app).toBeTruthy(); + })); + + it(`should have as title 'app'`, async(() => { + const fixture = TestBed.createComponent(AppComponent); + const app = fixture.debugElement.componentInstance; + expect(app.title).toEqual('app'); + })); + + it('should render title in a h1 tag', async(() => { + const fixture = TestBed.createComponent(AppComponent); + fixture.detectChanges(); + const compiled = fixture.debugElement.nativeElement; + expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!!'); + })); +}); diff --git a/guest/webservices/rest-client/rest-client/src/app/app.component.ts b/guest/webservices/rest-client/rest-client/src/app/app.component.ts new file mode 100644 index 0000000000..7b0f672831 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/app/app.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-root', + templateUrl: './app.component.html', + styleUrls: ['./app.component.css'] +}) +export class AppComponent { + title = 'app'; +} diff --git a/guest/webservices/rest-client/rest-client/src/app/app.module.ts b/guest/webservices/rest-client/rest-client/src/app/app.module.ts new file mode 100644 index 0000000000..fe90536b1e --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/app/app.module.ts @@ -0,0 +1,25 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; +import { HttpModule } from '@angular/http'; +import { FormsModule } from '@angular/forms'; + +import { AppComponent } from './app.component'; +import { UsersComponent } from './users.component'; +import { RouterModule } from '@angular/router'; + +@NgModule({ + declarations: [ + AppComponent, + UsersComponent + ], + imports: [ + BrowserModule, + HttpModule, + FormsModule, + RouterModule.forRoot([ + { path: '', component: AppComponent }, + { path: 'users', component: UsersComponent }])], + providers: [], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/guest/webservices/rest-client/rest-client/src/app/app.service.ts b/guest/webservices/rest-client/rest-client/src/app/app.service.ts new file mode 100644 index 0000000000..cf57aecbc9 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/app/app.service.ts @@ -0,0 +1,36 @@ +import {Injectable} from '@angular/core'; +import { Http, Response, Headers, RequestOptions } from '@angular/http'; +import 'rxjs/add/operator/map'; + +export class User { + constructor( + public email: string, + public name: string) { } +} + +@Injectable() +export class UserService { + constructor( + private _http: Http){} + + url = 'http://localhost:8080/rest-server/users'; + + addUser(user){ + let headers = new Headers({'Content-Type': 'application/json'}); + let options = new RequestOptions({ headers: headers}); + + return this._http.post(this.url, JSON.stringify(user), options) + .map( + (_response: Response) => { + return _response; + }, + err => alert('Error adding user')); + } + + getUsers() { + return this._http.get(this.url) + .map((_response: Response) => { + return _response.json(); + }); + } +} \ No newline at end of file diff --git a/guest/webservices/rest-client/rest-client/src/app/users.component.html b/guest/webservices/rest-client/rest-client/src/app/users.component.html new file mode 100644 index 0000000000..bbf9289080 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/app/users.component.html @@ -0,0 +1,15 @@ +
+Email:
+Name:
+ +
+ +
+ + + + + +
{{user.email}} +{{user.name}}
+ diff --git a/guest/webservices/rest-client/rest-client/src/app/users.component.ts b/guest/webservices/rest-client/rest-client/src/app/users.component.ts new file mode 100644 index 0000000000..6c5a383848 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/app/users.component.ts @@ -0,0 +1,39 @@ +import { Component } from '@angular/core'; +import {UserService, User} from './app.service'; + +@Component({ + selector: 'users-page', + providers: [UserService], + templateUrl: './users.component.html', + styleUrls: ['./app.component.css'] +}) +export class UsersComponent { + title = 'Users'; + + constructor( + private _service:UserService){} + + public user = {email: "", name: ""}; + public res=[]; + + addUser() { + this._service.addUser(this.user) + .subscribe( () => this.getUsers()); + } + + getUsers() { + this._service.getUsers() + .subscribe( + users => { + this.res=[]; + users.forEach(usr => { + this.res.push( + new User( + usr.email, + usr.name + ) + ) + }); + }); + } +} diff --git a/guest/webservices/rest-client/rest-client/src/assets/.gitkeep b/guest/webservices/rest-client/rest-client/src/assets/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts b/guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts new file mode 100644 index 0000000000..3612073bc3 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/environments/environment.prod.ts @@ -0,0 +1,3 @@ +export const environment = { + production: true +}; diff --git a/guest/webservices/rest-client/rest-client/src/environments/environment.ts b/guest/webservices/rest-client/rest-client/src/environments/environment.ts new file mode 100644 index 0000000000..b7f639aeca --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/environments/environment.ts @@ -0,0 +1,8 @@ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `.angular-cli.json`. + +export const environment = { + production: false +}; diff --git a/guest/webservices/rest-client/rest-client/src/favicon.ico b/guest/webservices/rest-client/rest-client/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..8081c7ceaf2be08bf59010158c586170d9d2d517 GIT binary patch literal 5430 zcmc(je{54#6vvCoAI3i*G5%$U7!sA3wtMZ$fH6V9C`=eXGJb@R1%(I_{vnZtpD{6n z5Pl{DmxzBDbrB>}`90e12m8T*36WoeDLA&SD_hw{H^wM!cl_RWcVA!I+x87ee975; z@4kD^=bYPn&pmG@(+JZ`rqQEKxW<}RzhW}I!|ulN=fmjVi@x{p$cC`)5$a!)X&U+blKNvN5tg=uLvuLnuqRM;Yc*swiexsoh#XPNu{9F#c`G zQLe{yWA(Y6(;>y|-efAy11k<09(@Oo1B2@0`PtZSkqK&${ zgEY}`W@t{%?9u5rF?}Y7OL{338l*JY#P!%MVQY@oqnItpZ}?s z!r?*kwuR{A@jg2Chlf0^{q*>8n5Ir~YWf*wmsh7B5&EpHfd5@xVaj&gqsdui^spyL zB|kUoblGoO7G(MuKTfa9?pGH0@QP^b#!lM1yHWLh*2iq#`C1TdrnO-d#?Oh@XV2HK zKA{`eo{--^K&MW66Lgsktfvn#cCAc*(}qsfhrvOjMGLE?`dHVipu1J3Kgr%g?cNa8 z)pkmC8DGH~fG+dlrp(5^-QBeEvkOvv#q7MBVLtm2oD^$lJZx--_=K&Ttd=-krx(Bb zcEoKJda@S!%%@`P-##$>*u%T*mh+QjV@)Qa=Mk1?#zLk+M4tIt%}wagT{5J%!tXAE;r{@=bb%nNVxvI+C+$t?!VJ@0d@HIyMJTI{vEw0Ul ze(ha!e&qANbTL1ZneNl45t=#Ot??C0MHjjgY8%*mGisN|S6%g3;Hlx#fMNcL<87MW zZ>6moo1YD?P!fJ#Jb(4)_cc50X5n0KoDYfdPoL^iV`k&o{LPyaoqMqk92wVM#_O0l z09$(A-D+gVIlq4TA&{1T@BsUH`Bm=r#l$Z51J-U&F32+hfUP-iLo=jg7Xmy+WLq6_tWv&`wDlz#`&)Jp~iQf zZP)tu>}pIIJKuw+$&t}GQuqMd%Z>0?t%&BM&Wo^4P^Y z)c6h^f2R>X8*}q|bblAF?@;%?2>$y+cMQbN{X$)^R>vtNq_5AB|0N5U*d^T?X9{xQnJYeU{ zoZL#obI;~Pp95f1`%X3D$Mh*4^?O?IT~7HqlWguezmg?Ybq|7>qQ(@pPHbE9V?f|( z+0xo!#m@Np9PljsyxBY-UA*{U*la#8Wz2sO|48_-5t8%_!n?S$zlGe+NA%?vmxjS- zHE5O3ZarU=X}$7>;Okp(UWXJxI%G_J-@IH;%5#Rt$(WUX?6*Ux!IRd$dLP6+SmPn= z8zjm4jGjN772R{FGkXwcNv8GBcZI#@Y2m{RNF_w8(Z%^A*!bS*!}s6sh*NnURytky humW;*g7R+&|Ledvc- + + + + RestClient + + + + + + + + + diff --git a/guest/webservices/rest-client/rest-client/src/main.ts b/guest/webservices/rest-client/rest-client/src/main.ts new file mode 100644 index 0000000000..a9ca1caf8c --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/main.ts @@ -0,0 +1,11 @@ +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { AppModule } from './app/app.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic().bootstrapModule(AppModule); diff --git a/guest/webservices/rest-client/rest-client/src/polyfills.ts b/guest/webservices/rest-client/rest-client/src/polyfills.ts new file mode 100644 index 0000000000..fd01cc9f1d --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/polyfills.ts @@ -0,0 +1,73 @@ +/** + * This file includes polyfills needed by Angular and is loaded before the app. + * You can add your own extra polyfills to this file. + * + * This file is divided into 2 sections: + * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. + * 2. Application imports. Files imported after ZoneJS that should be loaded before your main + * file. + * + * The current setup is for so-called "evergreen" browsers; the last versions of browsers that + * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), + * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. + * + * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html + */ + +/*************************************************************************************************** + * BROWSER POLYFILLS + */ + +/** IE9, IE10 and IE11 requires all of the following polyfills. **/ +// import 'core-js/es6/symbol'; +// import 'core-js/es6/object'; +// import 'core-js/es6/function'; +// import 'core-js/es6/parse-int'; +// import 'core-js/es6/parse-float'; +// import 'core-js/es6/number'; +// import 'core-js/es6/math'; +// import 'core-js/es6/string'; +// import 'core-js/es6/date'; +// import 'core-js/es6/array'; +// import 'core-js/es6/regexp'; +// import 'core-js/es6/map'; +// import 'core-js/es6/weak-map'; +// import 'core-js/es6/set'; + +/** IE10 and IE11 requires the following for NgClass support on SVG elements */ +// import 'classlist.js'; // Run `npm install --save classlist.js`. + +/** IE10 and IE11 requires the following to support `@angular/animation`. */ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + +/** Evergreen browsers require these. **/ +import 'core-js/es6/reflect'; +import 'core-js/es7/reflect'; + + +/** ALL Firefox browsers require the following to support `@angular/animation`. **/ +// import 'web-animations-js'; // Run `npm install --save web-animations-js`. + + + +/*************************************************************************************************** + * Zone JS is required by Angular itself. + */ +import 'zone.js/dist/zone'; // Included with Angular CLI. + + + +/*************************************************************************************************** + * APPLICATION IMPORTS + */ + +/** + * Date, currency, decimal and percent pipes. + * Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10 + */ +// import 'intl'; // Run `npm install --save intl`. +/** + * Need to import at least one locale-data with intl. + */ +// import 'intl/locale-data/jsonp/en'; diff --git a/guest/webservices/rest-client/rest-client/src/styles.css b/guest/webservices/rest-client/rest-client/src/styles.css new file mode 100644 index 0000000000..90d4ee0072 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/styles.css @@ -0,0 +1 @@ +/* You can add global styles to this file, and also import other style files */ diff --git a/guest/webservices/rest-client/rest-client/src/test.ts b/guest/webservices/rest-client/rest-client/src/test.ts new file mode 100644 index 0000000000..cd612eeb0e --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/test.ts @@ -0,0 +1,32 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/long-stack-trace-zone'; +import 'zone.js/dist/proxy.js'; +import 'zone.js/dist/sync-test'; +import 'zone.js/dist/jasmine-patch'; +import 'zone.js/dist/async-test'; +import 'zone.js/dist/fake-async-test'; +import { getTestBed } from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. +declare const __karma__: any; +declare const require: any; + +// Prevent Karma from running prematurely. +__karma__.loaded = function () {}; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); +// Then we find all the tests. +const context = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +context.keys().map(context); +// Finally, start Karma to run the tests. +__karma__.start(); diff --git a/guest/webservices/rest-client/rest-client/src/tsconfig.app.json b/guest/webservices/rest-client/rest-client/src/tsconfig.app.json new file mode 100644 index 0000000000..5e2507db58 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/tsconfig.app.json @@ -0,0 +1,13 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/app", + "module": "es2015", + "baseUrl": "", + "types": [] + }, + "exclude": [ + "test.ts", + "**/*.spec.ts" + ] +} diff --git a/guest/webservices/rest-client/rest-client/src/tsconfig.spec.json b/guest/webservices/rest-client/rest-client/src/tsconfig.spec.json new file mode 100644 index 0000000000..510e3f1fda --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "../out-tsc/spec", + "module": "commonjs", + "target": "es5", + "baseUrl": "", + "types": [ + "jasmine", + "node" + ] + }, + "files": [ + "test.ts" + ], + "include": [ + "**/*.spec.ts", + "**/*.d.ts" + ] +} diff --git a/guest/webservices/rest-client/rest-client/src/typings.d.ts b/guest/webservices/rest-client/rest-client/src/typings.d.ts new file mode 100644 index 0000000000..ef5c7bd620 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/src/typings.d.ts @@ -0,0 +1,5 @@ +/* SystemJS module definition */ +declare var module: NodeModule; +interface NodeModule { + id: string; +} diff --git a/guest/webservices/rest-client/rest-client/tsconfig.json b/guest/webservices/rest-client/rest-client/tsconfig.json new file mode 100644 index 0000000000..a35a8ee3a4 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "baseUrl": "src", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es5", + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2016", + "dom" + ] + } +} diff --git a/guest/webservices/rest-client/rest-client/tslint.json b/guest/webservices/rest-client/rest-client/tslint.json new file mode 100644 index 0000000000..dd117b3871 --- /dev/null +++ b/guest/webservices/rest-client/rest-client/tslint.json @@ -0,0 +1,135 @@ +{ + "rulesDirectory": [ + "node_modules/codelyzer" + ], + "rules": { + "arrow-return-shorthand": true, + "callable-types": true, + "class-name": true, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": true, + "forin": true, + "import-blacklist": [ + true, + "rxjs" + ], + "import-spacing": true, + "indent": [ + true, + "spaces" + ], + "interface-over-type-literal": true, + "label-position": true, + "max-line-length": [ + true, + 140 + ], + "member-access": false, + "member-ordering": [ + true, + "static-before-instance", + "variables-before-functions" + ], + "no-arg": true, + "no-bitwise": true, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-super": true, + "no-empty": false, + "no-empty-interface": true, + "no-eval": true, + "no-inferrable-types": [ + true, + "ignore-params" + ], + "no-misused-new": true, + "no-non-null-assertion": true, + "no-shadowed-variable": true, + "no-string-literal": false, + "no-string-throw": true, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": true, + "no-unnecessary-initializer": true, + "no-unused-expression": true, + "no-use-before-declare": true, + "no-var-keyword": true, + "object-literal-sort-keys": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "prefer-const": true, + "quotemark": [ + true, + "single" + ], + "radix": true, + "semicolon": [ + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace", + "index-signature": "nospace", + "parameter": "nospace", + "property-declaration": "nospace", + "variable-declaration": "nospace" + } + ], + "typeof-compare": true, + "unified-signatures": true, + "variable-name": false, + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ], + "directive-selector": [ + true, + "attribute", + "app", + "camelCase" + ], + "component-selector": [ + true, + "element", + "app", + "kebab-case" + ], + "use-input-property-decorator": true, + "use-output-property-decorator": true, + "use-host-property-decorator": true, + "no-input-rename": true, + "no-output-rename": true, + "use-life-cycle-interface": true, + "use-pipe-transform-interface": true, + "component-class-suffix": true, + "directive-class-suffix": true, + "no-access-missing-member": true, + "templates-use-public": true, + "invoke-injectable": true + } +} diff --git a/guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF b/guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..254272e1c0 --- /dev/null +++ b/guest/webservices/rest-server/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/guest/webservices/rest-server/WebContent/WEB-INF/web.xml b/guest/webservices/rest-server/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..46b173c59a --- /dev/null +++ b/guest/webservices/rest-server/WebContent/WEB-INF/web.xml @@ -0,0 +1,20 @@ + + + rest-server + + rest-server + org.glassfish.jersey.servlet.ServletContainer + + javax.ws.rs.Application + com.stackify.ApplicationInitializer + + 1 + + + rest-server + /* + + \ No newline at end of file diff --git a/guest/webservices/rest-server/pom.xml b/guest/webservices/rest-server/pom.xml new file mode 100644 index 0000000000..350e7eb9c9 --- /dev/null +++ b/guest/webservices/rest-server/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + com.stackify + rest-server + 0.0.1-SNAPSHOT + war + + + + org.glassfish.jersey.containers + jersey-container-servlet + 2.25.1 + + + org.glassfish.jersey.media + jersey-media-moxy + 2.25.1 + + + io.rest-assured + rest-assured + 3.0.3 + + + junit + junit + 4.12 + + + + + + + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + maven-war-plugin + 3.0.0 + + WebContent + + + + + \ No newline at end of file diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java b/guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java new file mode 100644 index 0000000000..6d864e859e --- /dev/null +++ b/guest/webservices/rest-server/src/main/java/com/stackify/ApplicationInitializer.java @@ -0,0 +1,9 @@ +package com.stackify; + +import org.glassfish.jersey.server.ResourceConfig; + +public class ApplicationInitializer extends ResourceConfig { + public ApplicationInitializer() { + packages("com.stackify.services"); + } +} diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/models/User.java b/guest/webservices/rest-server/src/main/java/com/stackify/models/User.java new file mode 100644 index 0000000000..8c8073357d --- /dev/null +++ b/guest/webservices/rest-server/src/main/java/com/stackify/models/User.java @@ -0,0 +1,43 @@ +package com.stackify.models; + +import javax.ws.rs.core.Link; + +public class User { + private String email; + private String name; + private Link link; + + public User() { + } + + public User(String email, String name) { + super(); + this.email = email; + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Link getLink() { + return link; + } + + public void setLink(Link link) { + this.link = link; + } + +} diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java b/guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java new file mode 100644 index 0000000000..267aa6fd61 --- /dev/null +++ b/guest/webservices/rest-server/src/main/java/com/stackify/services/CorsFilter.java @@ -0,0 +1,19 @@ +package com.stackify.services; + +import java.io.IOException; + +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; +import javax.ws.rs.ext.Provider; + +@Provider +public class CorsFilter implements ContainerResponseFilter { + + @Override + public void filter(final ContainerRequestContext requestContext, + final ContainerResponseContext response) throws IOException { + response.getHeaders().add("Access-Control-Allow-Origin", "*"); + response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept"); + } +} diff --git a/guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java b/guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java new file mode 100644 index 0000000000..e78ed4627a --- /dev/null +++ b/guest/webservices/rest-server/src/main/java/com/stackify/services/UserService.java @@ -0,0 +1,33 @@ +package com.stackify.services; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import com.stackify.models.User; + +@Path("/users") +public class UserService { + private static List users = new ArrayList<>(); + + @POST + @Consumes(MediaType.APPLICATION_JSON) + public Response addUser(User user) { + users.add(user); + return Response.ok() + .build(); + } + + @GET + @Produces(MediaType.APPLICATION_JSON) + public List getUsers() { + return users; + } +} diff --git a/guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceTest.java b/guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceTest.java new file mode 100644 index 0000000000..064951fbbe --- /dev/null +++ b/guest/webservices/rest-server/src/test/java/com/stackify/services/UserServiceTest.java @@ -0,0 +1,34 @@ +package com.stackify.services; + +import org.junit.Test; + +import io.restassured.RestAssured; +import static io.restassured.RestAssured.*; +import static org.hamcrest.CoreMatchers.*; + +public class UserServiceTest { + @Test + public void whenAddUser_thenGetUserOk() { + RestAssured.baseURI = "http://localhost:8080/rest-server"; + + //@formatter:off + + String json = "{\"email\":\"john@gmail.com\",\"name\":\"John\"}"; + given() + .contentType("application/json") + .body(json) + .when() + .post("/users") + .then() + .statusCode(200); + + when() + .get("/users") + .then() + .contentType("application/json") + .body("name", hasItem("John")) + .body("email", hasItem("john@gmail.com")); + + //@formatter:on + } +} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java b/guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java new file mode 100644 index 0000000000..5542fbde20 --- /dev/null +++ b/guest/webservices/soap_client/src/main/java/com/stackify/JAXWSClient.java @@ -0,0 +1,19 @@ +package com.stackify; + +import com.stackify.services.DefaultUserImplService; +import com.stackify.services.User; +import com.stackify.services.UserService; +import com.stackify.services.Users; + +public class JAXWSClient { + public static void main(String[] args) { + DefaultUserImplService service = new DefaultUserImplService(); + User user = new User(); + user.setEmail("john@gmail.com"); + user.setName("John"); + UserService port = service.getDefaultUserImplPort(); + port.addUser(user); + Users users = port.getUsers(); + System.out.println(users.getUsers().iterator().next().getName()); + } +} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java new file mode 100644 index 0000000000..821b969166 --- /dev/null +++ b/guest/webservices/soap_client/src/main/java/com/stackify/services/DefaultUserImplService.java @@ -0,0 +1,94 @@ + +package com.stackify.services; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "DefaultUserImplService", targetNamespace = "http://services.stackify.com/", wsdlLocation = "http://localhost:8080/users?wsdl") +public class DefaultUserImplService + extends Service +{ + + private final static URL DEFAULTUSERIMPLSERVICE_WSDL_LOCATION; + private final static WebServiceException DEFAULTUSERIMPLSERVICE_EXCEPTION; + private final static QName DEFAULTUSERIMPLSERVICE_QNAME = new QName("http://services.stackify.com/", "DefaultUserImplService"); + + static { + URL url = null; + WebServiceException e = null; + try { + url = new URL("http://localhost:8080/users?wsdl"); + } catch (MalformedURLException ex) { + e = new WebServiceException(ex); + } + DEFAULTUSERIMPLSERVICE_WSDL_LOCATION = url; + DEFAULTUSERIMPLSERVICE_EXCEPTION = e; + } + + public DefaultUserImplService() { + super(__getWsdlLocation(), DEFAULTUSERIMPLSERVICE_QNAME); + } + + public DefaultUserImplService(WebServiceFeature... features) { + super(__getWsdlLocation(), DEFAULTUSERIMPLSERVICE_QNAME, features); + } + + public DefaultUserImplService(URL wsdlLocation) { + super(wsdlLocation, DEFAULTUSERIMPLSERVICE_QNAME); + } + + public DefaultUserImplService(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, DEFAULTUSERIMPLSERVICE_QNAME, features); + } + + public DefaultUserImplService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public DefaultUserImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns UserService + */ + @WebEndpoint(name = "DefaultUserImplPort") + public UserService getDefaultUserImplPort() { + return super.getPort(new QName("http://services.stackify.com/", "DefaultUserImplPort"), UserService.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns UserService + */ + @WebEndpoint(name = "DefaultUserImplPort") + public UserService getDefaultUserImplPort(WebServiceFeature... features) { + return super.getPort(new QName("http://services.stackify.com/", "DefaultUserImplPort"), UserService.class, features); + } + + private static URL __getWsdlLocation() { + if (DEFAULTUSERIMPLSERVICE_EXCEPTION!= null) { + throw DEFAULTUSERIMPLSERVICE_EXCEPTION; + } + return DEFAULTUSERIMPLSERVICE_WSDL_LOCATION; + } + +} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java new file mode 100644 index 0000000000..d992521d9f --- /dev/null +++ b/guest/webservices/soap_client/src/main/java/com/stackify/services/ObjectFactory.java @@ -0,0 +1,48 @@ + +package com.stackify.services; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.stackify.services package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.stackify.services + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link User } + * + */ + public User createUser() { + return new User(); + } + + /** + * Create an instance of {@link Users } + * + */ + public Users createUsers() { + return new Users(); + } + +} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/User.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/User.java new file mode 100644 index 0000000000..d9d517f83d --- /dev/null +++ b/guest/webservices/soap_client/src/main/java/com/stackify/services/User.java @@ -0,0 +1,87 @@ + +package com.stackify.services; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for user complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="user">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="email" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "user", propOrder = { + "email", + "name" +}) +public class User { + + protected String email; + protected String name; + + /** + * Gets the value of the email property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getEmail() { + return email; + } + + /** + * Sets the value of the email property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setEmail(String value) { + this.email = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java new file mode 100644 index 0000000000..87ab1f2f75 --- /dev/null +++ b/guest/webservices/soap_client/src/main/java/com/stackify/services/UserService.java @@ -0,0 +1,47 @@ + +package com.stackify.services; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.Action; + + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.2.9-b130926.1035 + * Generated source version: 2.2 + * + */ +@WebService(name = "UserService", targetNamespace = "http://services.stackify.com/") +@SOAPBinding(style = SOAPBinding.Style.RPC) +@XmlSeeAlso({ + ObjectFactory.class +}) +public interface UserService { + + + /** + * + * @param arg0 + */ + @WebMethod + @Action(input = "http://services.stackify.com/UserService/addUserRequest", output = "http://services.stackify.com/UserService/addUserResponse") + public void addUser( + @WebParam(name = "arg0", partName = "arg0") + User arg0); + + /** + * + * @return + * returns com.stackify.services.Users + */ + @WebMethod + @WebResult(partName = "return") + @Action(input = "http://services.stackify.com/UserService/getUsersRequest", output = "http://services.stackify.com/UserService/getUsersResponse") + public Users getUsers(); + +} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java new file mode 100644 index 0000000000..bde0e47b11 --- /dev/null +++ b/guest/webservices/soap_client/src/main/java/com/stackify/services/Users.java @@ -0,0 +1,69 @@ + +package com.stackify.services; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for users complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="users">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="users" type="{http://services.stackify.com/}user" maxOccurs="unbounded" minOccurs="0"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "users", propOrder = { + "users" +}) +public class Users { + + @XmlElement(nillable = true) + protected List users; + + /** + * Gets the value of the users property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the users property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getUsers().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link User } + * + * + */ + public List getUsers() { + if (users == null) { + users = new ArrayList(); + } + return this.users; + } + +} diff --git a/guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java b/guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java new file mode 100644 index 0000000000..af6d2bc25e --- /dev/null +++ b/guest/webservices/soap_client/src/main/java/com/stackify/services/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://services.stackify.com/") +package com.stackify.services; diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java b/guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java new file mode 100644 index 0000000000..3a10b6e285 --- /dev/null +++ b/guest/webservices/soap_example/src/main/java/com/stackify/ServicePublisher.java @@ -0,0 +1,11 @@ +package com.stackify; + +import javax.xml.ws.Endpoint; + +import com.stackify.services.DefaultUserImpl; + +public class ServicePublisher { + public static void main(String[] args) { + Endpoint.publish("http://localhost:8080/users", new DefaultUserImpl()); + } +} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/models/User.java b/guest/webservices/soap_example/src/main/java/com/stackify/models/User.java new file mode 100644 index 0000000000..1a9741154d --- /dev/null +++ b/guest/webservices/soap_example/src/main/java/com/stackify/models/User.java @@ -0,0 +1,32 @@ +package com.stackify.models; + +public class User { + private String email; + private String name; + + public User() { + } + + public User(String email, String name) { + super(); + this.email = email; + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java b/guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java new file mode 100644 index 0000000000..2323a74614 --- /dev/null +++ b/guest/webservices/soap_example/src/main/java/com/stackify/models/Users.java @@ -0,0 +1,16 @@ +package com.stackify.models; + +import java.util.List; + +public class Users { + List users; + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + +} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java b/guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java new file mode 100644 index 0000000000..87d7d646c1 --- /dev/null +++ b/guest/webservices/soap_example/src/main/java/com/stackify/services/DefaultUserImpl.java @@ -0,0 +1,27 @@ +package com.stackify.services; + +import java.util.ArrayList; + +import javax.jws.WebService; + +import com.stackify.models.User; +import com.stackify.models.Users; + +@WebService(endpointInterface = "com.stackify.services.UserService") +public class DefaultUserImpl implements UserService { + + ArrayList usersList = new ArrayList<>(); + + @Override + public void addUser(User user) { + usersList.add(user); + } + + @Override + public Users getUsers() { + Users users = new Users(); + users.setUsers(usersList); + return users; + } + +} diff --git a/guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java b/guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java new file mode 100644 index 0000000000..8c57fbd061 --- /dev/null +++ b/guest/webservices/soap_example/src/main/java/com/stackify/services/UserService.java @@ -0,0 +1,19 @@ +package com.stackify.services; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; + +import com.stackify.models.User; +import com.stackify.models.Users; + +@WebService +@SOAPBinding(style = SOAPBinding.Style.RPC) +public interface UserService { + + @WebMethod + public void addUser(User user); + + @WebMethod + public Users getUsers(); +} diff --git a/guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF b/guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..254272e1c0 --- /dev/null +++ b/guest/webservices/spring-rest-service/WebContent/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Class-Path: + diff --git a/guest/webservices/spring-rest-service/pom.xml b/guest/webservices/spring-rest-service/pom.xml new file mode 100644 index 0000000000..11082cf17b --- /dev/null +++ b/guest/webservices/spring-rest-service/pom.xml @@ -0,0 +1,48 @@ + + 4.0.0 + com.stackify + spring-rest-service + 0.0.1-SNAPSHOT + war + + + org.springframework.boot + spring-boot-starter-parent + 1.5.4.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-hateoas + + + io.springfox + springfox-swagger2 + 2.7.0 + + + io.springfox + springfox-swagger-ui + 2.7.0 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java new file mode 100644 index 0000000000..b45ed8094f --- /dev/null +++ b/guest/webservices/spring-rest-service/src/main/java/com/stackify/Application.java @@ -0,0 +1,12 @@ +package com.stackify; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java new file mode 100644 index 0000000000..0e9567b452 --- /dev/null +++ b/guest/webservices/spring-rest-service/src/main/java/com/stackify/config/SwaggerConfig.java @@ -0,0 +1,22 @@ +package com.stackify.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2).select() + .apis(RequestHandlerSelectors.basePackage("com.stackify.controllers")) + .paths(PathSelectors.any()) + .build(); + } +} diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java new file mode 100644 index 0000000000..361dbde38d --- /dev/null +++ b/guest/webservices/spring-rest-service/src/main/java/com/stackify/controllers/UserController.java @@ -0,0 +1,52 @@ +package com.stackify.controllers; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.hateoas.Link; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.stackify.models.User; +import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; +import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; + +@RestController +public class UserController { + + private static List users = new ArrayList<>(); + + @PostMapping(value = "/users", consumes = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.CREATED) + public void addUser(@RequestBody User user) { + users.add(user); + } + + @GetMapping("/users") + public List getUsers() { + users.forEach(user -> { + Link selfLink = linkTo(methodOn(UserController.class).getUsers()).slash(user.getEmail()) + .withSelfRel(); + user.getLinks().clear(); + user.add(selfLink); + }); + return users; + } + + @GetMapping("/users/{email}") + public User getUser(@PathVariable String email) { + User us = users.stream() + .filter(user -> !user.getEmail() + .equals(email)) + .findAny() + .orElse(null); + return us; + } + +} diff --git a/guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java b/guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java new file mode 100644 index 0000000000..b52e7f0f87 --- /dev/null +++ b/guest/webservices/spring-rest-service/src/main/java/com/stackify/models/User.java @@ -0,0 +1,34 @@ +package com.stackify.models; + +import org.springframework.hateoas.ResourceSupport; + +public class User extends ResourceSupport { + private String email; + private String name; + + public User() { + } + + public User(String email, String name) { + super(); + this.email = email; + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +}