Monday, February 9, 2015

Generate JAX-WS client from WSDL file/URL using wsimport tool

wsimport tool available in $JDK/bin folder.

We can use this wsimport tool to parse a certain WSDL file of the server and generate client files (JAX-WS portable artifacts) to access server's published service.

Suhans-MacBook-Pro:client suhanr$ ls
RemoteUserStoreManagerService.wsdl
Suhans-MacBook-Pro:client suhanr$ wsimport -d /WSO2/wsimport_test/client/ RemoteUserStoreManagerService.wsdl
parsing WSDL...

[WARNING] src-resolve: Cannot resolve the name 'ax2605:UserStoreException' to a(n) 'type definition' component.
  line 83 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl#types?schema4

[WARNING] src-resolve: Cannot resolve the name 'ax2609:ClaimDTO' to a(n) 'type definition' component.
  line 147 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl#types?schema4

[WARNING] src-resolve: Cannot resolve the name 'ax2612:Tenant' to a(n) 'type definition' component.
  line 462 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl#types?schema4

[WARNING] Ignoring SOAP port "RemoteUserStoreManagerServiceHttpsSoap12Endpoint": it uses non-standard SOAP 1.2 binding.
You must specify the "-extension" option to use this binding.
  line 1785 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl

[WARNING] ignoring port "RemoteUserStoreManagerServiceHttpsEndpoint": no SOAP address specified. try running wsimport with -extension switch.
  line 1788 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl

[WARNING] src-resolve: Cannot resolve the name 'ax2605:UserStoreException' to a(n) 'type definition' component.
  line 83 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl#types?schema4

[WARNING] src-resolve: Cannot resolve the name 'ax2609:ClaimDTO' to a(n) 'type definition' component.
  line 147 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl#types?schema4

[WARNING] src-resolve: Cannot resolve the name 'ax2612:Tenant' to a(n) 'type definition' component.
  line 462 of file:/WSO2/wsimport_test/client/RemoteUserStoreManagerService.wsdl#types?schema4

generating code...

compiling code...

If you are locally having the server up and running, get the wsdl link and make sure it is accessible via local web browser.

Your command may look like this,


Suhans-MacBook-Pro:client suhanr$ wsimport -d /WSO2/wsimport_test/client/ http://localhost:9763/services/RemoteUserStoreManagerService?wsdl

After generating the code,

Suhans-MacBook-Pro:client suhanr$ tree
.
├── RemoteUserStoreManagerService.wsdl
└── org
    └── wso2
        └── carbon
            ├── um
            │   └── ws
            │       └── service
            │           ├── AddRole.class
            │           ├── AddUser.class
            │           ├── AddUserClaimValue.class
            │           ├── AddUserClaimValues.class
            │           ├── ArrayOfString.class
            │           ├── Authenticate.class
            │           ├── AuthenticateResponse.class
            │           ├── DeleteRole.class
            │           ├── DeleteUser.class
            │           ├── DeleteUserClaimValue.class
            │           ├── DeleteUserClaimValues.class
            │           ├── GetAllProfileNames.class
            │           ├── GetAllProfileNamesResponse.class
            │           ├── GetHybridRoles.class
            │           ├── GetHybridRolesResponse.class
            │           ├── GetPasswordExpirationTime.class
            │           ├── GetPasswordExpirationTimeResponse.class
            │           ├── GetProfileNames.class
            │           ├── GetProfileNamesResponse.class
            │           ├── GetProperties.class
            │           ├── GetPropertiesResponse.class
            │           ├── GetRoleListOfUser.class
            │           ├── GetRoleListOfUserResponse.class
            │           ├── GetRoleNames.class
            │           ├── GetRoleNamesResponse.class
            │           ├── GetTenantId.class
            │           ├── GetTenantIdResponse.class
            │           ├── GetTenantIdofUser.class
            │           ├── GetTenantIdofUserResponse.class
            │           ├── GetUserClaimValue.class
            │           ├── GetUserClaimValueResponse.class
            │           ├── GetUserClaimValues.class
            │           ├── GetUserClaimValuesForClaims.class
            │           ├── GetUserClaimValuesForClaimsResponse.class
            │           ├── GetUserClaimValuesResponse.class
            │           ├── GetUserId.class
            │           ├── GetUserIdResponse.class
            │           ├── GetUserList.class
            │           ├── GetUserListOfRole.class
            │           ├── GetUserListOfRoleResponse.class
            │           ├── GetUserListResponse.class
            │           ├── IsExistingRole.class
            │           ├── IsExistingRoleResponse.class
            │           ├── IsExistingUser.class
            │           ├── IsExistingUserResponse.class
            │           ├── IsReadOnly.class
            │           ├── IsReadOnlyResponse.class
            │           ├── ListUsers.class
            │           ├── ListUsersResponse.class
            │           ├── ObjectFactory.class
            │           ├── RemoteUserStoreManagerService.class
            │           ├── RemoteUserStoreManagerServicePortType.class
            │           ├── RemoteUserStoreManagerServiceUserStoreException.class
            │           ├── RemoteUserStoreManagerServiceUserStoreException_Exception.class
            │           ├── SetUserClaimValue.class
            │           ├── SetUserClaimValues.class
            │           ├── UpdateCredential.class
            │           ├── UpdateCredentialByAdmin.class
            │           ├── UpdateRoleListOfUser.class
            │           ├── UpdateRoleName.class
            │           ├── UpdateUserListOfRole.class
            │           ├── dao
            │           │   └── xsd
            │           │       ├── ClaimDTO.class
            │           │       ├── ObjectFactory.class
            │           │       ├── PermissionDTO.class
            │           │       └── package-info.class
            │           └── package-info.class
            └── user
                ├── api
                │   └── xsd
                │       ├── ObjectFactory.class
                │       ├── RealmConfiguration.class
                │       ├── Tenant.class
                │       ├── UserStoreException.class
                │       └── package-info.class
                ├── core
                │   ├── tenant
                │   │   └── xsd
                │   │       ├── ObjectFactory.class
                │   │       ├── Tenant.class
                │   │       └── package-info.class
                │   └── xsd
                │       ├── ObjectFactory.class
                │       ├── UserStoreException.class
                │       └── package-info.class
                └── mgt
                    └── common
                        └── xsd
                            ├── ClaimValue.class
                            ├── ObjectFactory.class
                            └── package-info.class

18 directories, 81 files

No comments:

Post a Comment