Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the SOAP module to support web service securities #103

Merged
merged 193 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 190 commits
Commits
Show all changes
193 commits
Select commit Hold shift + click to select a range
d161e0f
Move dependencies to stable version
Aug 14, 2023
1cbf4b0
[Gradle Release Plugin] - pre tag commit: 'v0.1.0'.
Aug 14, 2023
06fe373
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
6d37464
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
f184394
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
2c01c3a
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
c064ace
Update lang version to 2201.7.2
Nuvindu Sep 15, 2023
1f6bdf3
Refactor APIs to accept SOAP action as a parameter
Nuvindu Sep 15, 2023
5d28d3c
Update test cases for compatibility with modified APIs
Nuvindu Sep 15, 2023
f14011a
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
22f1571
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
a951771
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
7f332ea
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
318e44c
Set the SOAP action parameter defaultable
Nuvindu Sep 15, 2023
0c92530
Add test cases for SOAP 1.2 requests without the action parameter
Nuvindu Sep 15, 2023
8ab5a6a
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
259f52d
Format the code according to the coding conventions
Nuvindu Sep 15, 2023
99693da
Change the package version to 0.2.0
Nuvindu Sep 15, 2023
d152751
[Automated] Update the native jar versions
Nuvindu Sep 15, 2023
3d37a40
Change branch name `main` to `master` in github workflow files
Nuvindu Sep 18, 2023
a83e084
Remove `ballerina/io` dependency
Nuvindu Sep 18, 2023
0924bba
Change branch name `master` to `2201.7.x` in github workflow files
Nuvindu Sep 18, 2023
ff46559
[Automated] Update the native jar versions
Nuvindu Sep 24, 2023
067fceb
[Automated] Update the native jar versions
Nuvindu Sep 24, 2023
5b6937a
[Automated] Update the native jar versions
Nuvindu Sep 24, 2023
d7f26d9
[Automated] Update the native jar versions
Nuvindu Sep 24, 2023
00b2c9a
Refactor SOAP 1.1 and 1.2 versions into separate sub modules
Nuvindu Sep 25, 2023
9b252c2
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
56059d2
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
157275a
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
67371eb
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
2450c2a
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
49a226b
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
46db193
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
73cabce
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
3ed8f7c
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
a19a09a
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
58674cb
[Automated] Update the native jar versions
Nuvindu Sep 25, 2023
415602c
[Automated] Update the native jar versions
Nuvindu Sep 26, 2023
0d9fe8a
[Automated] Update the native jar versions
Nuvindu Sep 26, 2023
2aefe1c
[Automated] Update the native jar versions
Nuvindu Sep 26, 2023
7082ef5
[Automated] Update the native jar versions
Nuvindu Sep 26, 2023
c2df86e
[Automated] Update the native jar versions
Nuvindu Sep 27, 2023
b64da47
[Automated] Update the native jar versions
Nuvindu Oct 1, 2023
3d196cc
[Automated] Update the native jar versions
Nuvindu Oct 1, 2023
8ce19aa
[Automated] Update the native jar versions
Nuvindu Oct 1, 2023
521f5d0
[Automated] Update the native jar versions
Nuvindu Oct 1, 2023
54af277
[Automated] Update the native jar versions
Nuvindu Oct 1, 2023
fdcf462
[Automated] Update the native jar versions
Nuvindu Oct 1, 2023
50c4ba1
[Automated] Update the native jar versions
Nuvindu Oct 1, 2023
1c4bbbc
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
7763113
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
a4f612a
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
5d2a84c
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
5405b8f
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
271d250
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
a3871d6
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
9af7de6
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
dfeaa3e
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
ab14663
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
91a93f1
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
d50adb2
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
4624297
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
4d9d0af
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
3a57e92
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
a8c585b
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
f0f1cd0
[Automated] Update the native jar versions
Nuvindu Oct 2, 2023
32837df
[Automated] Update the native jar versions
Nuvindu Oct 3, 2023
4e243dd
Apply changes to support the 2201.8.0 lang version
Nuvindu Oct 3, 2023
d5c5c17
Add gradle wrapper files to the package
Nuvindu Oct 3, 2023
13b08b9
Update the .gitignore file
Nuvindu Oct 3, 2023
8e7f6c7
Update checkstyle and suppression files
Nuvindu Oct 3, 2023
a2f9c6d
Add dependencies to native files
Nuvindu Oct 3, 2023
c6a057e
Add changes to return module specific errors
Nuvindu Oct 3, 2023
cd5ee70
Create APIs to support signatures in SOAP envelopes
Nuvindu Oct 3, 2023
1dd24f5
Create APIs to support encryptions in SOAP envelopes
Nuvindu Oct 3, 2023
56e6c70
Create APIs to access data in SOAP envelopes
Nuvindu Oct 3, 2023
a12e29d
Create APIs to add security headers in SOAP envelopes
Nuvindu Oct 3, 2023
8c877d1
Apply changes to support username token security policy
Nuvindu Oct 3, 2023
e65dc4f
Apply changes to support timestamp token security policy
Nuvindu Oct 3, 2023
41eabf7
Apply changes to support symmetric binding security policy
Nuvindu Oct 3, 2023
0581d69
Add necessary APIs to encrypt and sign SOAP envelopes
Nuvindu Oct 3, 2023
4faef30
Apply changes to support asymmetric binding security policy
Nuvindu Oct 3, 2023
42b2325
Add static variables for string constants
Nuvindu Oct 3, 2023
c3fea30
Create a separate module for SOAP 1.1
Nuvindu Oct 3, 2023
a55b735
Create a separate module for SOAP 1.2
Nuvindu Oct 3, 2023
5ab5fa6
Apply changes to support transport binding security policy
Nuvindu Oct 3, 2023
0c6db3c
Add inbound and outbound security configs for SOAP clients
Nuvindu Oct 3, 2023
b39e65b
Add common APIs and configs into a separate module
Nuvindu Oct 3, 2023
2fc579c
Add enumerations for signature, encryption and password types
Nuvindu Oct 3, 2023
ec5737a
Modify the code to only export SOAP 1.1 and 1.2 modules
Nuvindu Oct 3, 2023
865417f
Add cryptographic files for test purposes
Nuvindu Oct 3, 2023
ec4c306
Add test cases for the wssec module
Nuvindu Oct 3, 2023
6211477
Add test cases for the SOAP 1.1 module
Nuvindu Oct 3, 2023
bc383ca
Add test cases for SOAP 1.2 module
Nuvindu Oct 3, 2023
bc93dcb
Add utility functions to verify SOAP envelopes
Nuvindu Oct 3, 2023
325f5f4
Merge branch 'ws-securities' of https://github.com/Nuvindu/module-bal…
Nuvindu Oct 3, 2023
241e0c8
Rename the file to `WsSecurityUtils`
Nuvindu Oct 3, 2023
1e57ac7
Add the .gitattributes file
Nuvindu Oct 3, 2023
f47b937
Add the ballerina `regex` dependency
Nuvindu Oct 3, 2023
7c36e75
Improve signature and verification methods
Nuvindu Oct 3, 2023
3b29eb1
Improve the API to decrypt data
Nuvindu Oct 3, 2023
473f51d
Add test cases to support all the signature algorithms
Nuvindu Oct 3, 2023
893d501
[Automated] Update the native jar versions
Nuvindu Oct 3, 2023
247f60f
[Automated] Update the native jar versions
Nuvindu Oct 3, 2023
282eb88
Add test cases for transport binding security
Nuvindu Oct 3, 2023
9e98fac
Add test cases for SOAP envelopes with ws securities
Nuvindu Oct 3, 2023
812cdc7
Remove unnecessary code segments and APIs
Nuvindu Oct 3, 2023
2a32261
Update error handling in SOAP clients
Nuvindu Oct 3, 2023
b65d5c5
[Automated] Update the native jar versions
Nuvindu Oct 4, 2023
d636912
[Automated] Update the native jar versions
Nuvindu Oct 4, 2023
3dba197
[Automated] Update the native jar versions
Nuvindu Oct 4, 2023
ffd57a4
[Automated] Update the native jar versions
Nuvindu Oct 4, 2023
3680256
Apply changes to adhere code coventions
Nuvindu Oct 4, 2023
ddbb1a9
Remove unnecessary string consts
Nuvindu Oct 4, 2023
b1e8339
Add test cases for SOAP 1.2 client with security
Nuvindu Oct 4, 2023
984abe6
Apply changes to adhere code conventions
Nuvindu Oct 4, 2023
e5a872e
Remove unnecessary code segments
Nuvindu Oct 4, 2023
449d488
Fix test case issue
Nuvindu Oct 4, 2023
f822ac8
Add const variable for a SOAP client error
Nuvindu Oct 5, 2023
439be7c
Change test case name
Nuvindu Oct 5, 2023
cc42bc9
Add security support for mime:Entity
Nuvindu Oct 5, 2023
b9ee921
[Automated] Update the native jar versions
Nuvindu Oct 5, 2023
9ebde88
Migrate `soap:common` module into the `soap` module
Nuvindu Oct 5, 2023
4551c29
Update the `http` version to 2.10.1
Nuvindu Oct 6, 2023
99b3fbe
Add configuration files for GraalVM checks
Nuvindu Oct 6, 2023
dff060d
Fix description name of the build.gradle file
Nuvindu Oct 6, 2023
3c0fc41
Add GraalVM native image dependency
Nuvindu Oct 6, 2023
74f1b93
Apply changes to adhere code conventions
Nuvindu Oct 6, 2023
032432d
Add necessary configurations for GraalVM checks
Nuvindu Oct 9, 2023
c5e5991
Apply changes according to suggestions
Nuvindu Oct 9, 2023
927c3fa
Add documentations for the public modules
Nuvindu Oct 9, 2023
3d11e9e
Fix documentation issue
Nuvindu Oct 9, 2023
fe486c3
[Automated] Update the native jar versions
Nuvindu Oct 10, 2023
73563e5
[Automated] Update the native jar versions
Nuvindu Oct 10, 2023
0634a1f
[Automated] Update the native jar versions
Nuvindu Oct 10, 2023
c331a85
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
d061f16
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
c0eded9
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
a9b1208
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
f7dbd30
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
69055c8
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
641ee07
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
d88f5ea
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
c009477
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
6c2dcdf
[Automated] Update the native jar versions
Nuvindu Oct 11, 2023
86b8cf5
Remove variable assignment from the `sendOnly` method
Nuvindu Oct 12, 2023
4181acf
[Automated] Update the native jar versions
Nuvindu Oct 12, 2023
38f4641
[Automated] Update the native jar versions
Nuvindu Oct 12, 2023
4d1ab49
[Automated] Update the native jar versions
Nuvindu Oct 12, 2023
6a649b7
[Automated] Update the native jar versions
Nuvindu Oct 12, 2023
bddc0ea
[Automated] Update the native jar versions
Nuvindu Oct 12, 2023
e574841
Remove `string` keyword from `const` variables
Nuvindu Oct 12, 2023
1de6750
Apply suggestions from the review
Nuvindu Oct 12, 2023
6f98be1
FIx license headers
Nuvindu Oct 12, 2023
045914d
[Automated] Update the native jar versions
Nuvindu Oct 12, 2023
1b1fbc9
[Automated] Update the native jar versions
Nuvindu Oct 12, 2023
0cb9492
[Automated] Update the native jar versions
Nuvindu Oct 13, 2023
d269974
[Automated] Update the native jar versions
Nuvindu Oct 13, 2023
2624834
Remove `regex` dependency
Nuvindu Oct 13, 2023
8f8331c
Make the modules isolated
Nuvindu Oct 13, 2023
5970f3c
Fix issues in supporting `mime:Entity[]` type requests
Nuvindu Oct 13, 2023
0d9c804
Merge branch 'ws-security-policies' of https://github.com/Nuvindu/mod…
Nuvindu Oct 13, 2023
999d4d3
Fix type checking in `if` statement
Nuvindu Oct 13, 2023
e9edbae
Remove unnecessary method
Nuvindu Oct 13, 2023
d7b7abf
Modify signature verification method
Nuvindu Oct 13, 2023
e505be0
Apply string template for `soapAction`
Nuvindu Oct 13, 2023
d5fc6c7
Add private constructor to the Constants class
Nuvindu Oct 13, 2023
181d7f5
Remove unnecessary method
Nuvindu Oct 13, 2023
35a7188
Fix repeating same key variables
Nuvindu Oct 13, 2023
358ce76
Add configurable variables for crypto keys
Nuvindu Oct 13, 2023
41b2c84
Replace string with static variable
Nuvindu Oct 13, 2023
d852fd8
Remove redundant test case
Nuvindu Oct 13, 2023
0739c63
Remove handle variable from `Document` class
Nuvindu Oct 13, 2023
7e830b3
[Automated] Update the native jar versions
Nuvindu Oct 13, 2023
85f7782
[Automated] Update the native jar versions
Nuvindu Oct 13, 2023
86c0f05
Change resource path name
Nuvindu Oct 13, 2023
4bfb7ea
Merge branch 'master' into ws-security-policies
Nuvindu Oct 13, 2023
5eed3f5
Fix license header issue
Nuvindu Oct 13, 2023
e8e5bc9
Apply suggestions from the review
Nuvindu Oct 13, 2023
39c33cc
Merge branch 'ws-security-policies' of https://github.com/Nuvindu/mod…
Nuvindu Oct 13, 2023
e309edb
Apply suggestions from the review
Nuvindu Oct 13, 2023
4731c3d
Fix unnecessary `else if` statement
Nuvindu Oct 14, 2023
e7a9ca9
Fix the code to send `<soap:Envelope>` instead of `<soap:Body>`
Nuvindu Oct 15, 2023
2255c48
Add resource functions to receive request from SOAP client
Nuvindu Oct 15, 2023
a04bc4b
Remove redundant methods
Nuvindu Oct 15, 2023
89ea49b
Add test cases for inbound and outbound configs in SOAP clients
Nuvindu Oct 15, 2023
8b3e472
[Automated] Update the native jar versions
Nuvindu Oct 15, 2023
90923f5
Fix license header
Nuvindu Oct 15, 2023
902844f
Apply suggestions from the review
Nuvindu Oct 15, 2023
14fc658
Add an empty line before the imports
Nuvindu Oct 16, 2023
97e1c39
Fix the errors to return cause
Nuvindu Oct 16, 2023
af0ac20
Fix removing unnecessary methods
Nuvindu Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ensure all Java files use LF.
*.java eol=lf
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,6 @@ target
# Ballerina
velocity.log*
*Ballerina.lock

.vscode
config-dir
208 changes: 206 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,213 @@ Ballerina SOAP Library
[![Github issues](https://img.shields.io/github/issues/ballerina-platform/ballerina-standard-library/module/soap.svg?label=Open%20Issues)](https://github.com/ballerina-platform/ballerina-standard-library/labels/module%2Fyaml)
[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerina-soap/branch/master/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerina-soap)

This library provides APIs to send an ordinary XML request to a SOAP backend by specifying the necessary details to construct a SOAP envelope.
This module offers a set of APIs that facilitate the transmission of XML requests to a SOAP backend. It excels in managing security policies within SOAP requests, ensuring the transmission of secured SOAP envelopes. Moreover, it possesses the capability to efficiently extract data from security-applied SOAP responses.

Soap module abstracts out the details of the creation of a SOAP envelope, headers, and the body in a SOAP message.
SOAP module abstracts out the details of the creation of a SOAP envelope, headers, and the body in a SOAP message.

## Client

The `Client` is used to connect to and interact with `SOAP` endpoints.

### SOAP 1.1 Client

```ballerina
import ballerina/soap:soap11;

soap11:Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL");
```

### SOAP 1.2 Client

```ballerina
import ballerina/soap:soap12;

soap12:Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL");
```

## APIs associated with SOAP

- **Send & Receive**: Sends SOAP request and receives a response.
- **Send Only**: Fires and forgets requests. Sends the request without the possibility of any response from the service.

The SOAP 1.1 specification requires the inclusion of the `action` parameter as a mandatory component within its APIs. In contrast, SOAP 1.2 relaxes this requirement, making the action parameter optional.

### Example: Send & Receive

```ballerina
import ballerina/soap:soap11;

public function main() returns error? {
soap11:Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL");

xml envelope = xml `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<quer:Add xmlns:quer="http://tempuri.org/">
<quer:intA>2</quer:intA>
<quer:intB>3</quer:intB>
</quer:Add>
</soap:Body>
</soap:Envelope>`;
xml|mime:Entity[] response = check soapClient->sendReceive(envelope, "http://tempuri.org/Add");
}
```

### Example: Send Only

```ballerina
import ballerina/soap:soap11;

public function main() returns error? {
soap11:Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL");

xml envelope = xml `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<quer:Add xmlns:quer="http://tempuri.org/">
<quer:intA>2</quer:intA>
<quer:intB>3</quer:intB>
</quer:Add>
</soap:Body>
</soap:Envelope>`;
check soapClient->sendOnly(envelope, "http://tempuri.org/Add");
}
```

## Security

The SOAP client module introduces a robust framework for configuring security measures in SOAP communication. Security is a critical concern when exchanging data via web services, and this module offers comprehensive options to fortify SOAP requests and responses.

There are two primary security configurations available for SOAP clients:

- `inboundSecurity`: This configuration is applied to the SOAP envelope when a request is made. It includes various ws security policies such as Username Token, Timestamp Token, X509 Token, Symmetric Binding, Asymmetric Binding, and Transport Binding, either individually or in combination with each other.

- `outboundSecurity`: This configuration is applied to the SOAP envelope when a response is received. Its purpose is to decrypt the data within the envelope and verify the digital signature for security validation.

### Policies

This library currently supports the following WS Security policies:

- **Username Token**: Provides authentication through username and password credentials.
- **Timestamp Token**: Enhances message integrity by incorporating timestamp information.
- **X509 Token**: Allows the use of X.509 certificates for secure communication.
- **Symmetric Binding**: Enables symmetric key-based security mechanisms.
- **Asymmetric Binding**: Facilitates the use of asymmetric cryptography for enhanced security.

These policies empower SOAP clients to enhance the security of their web service communications by selecting and implementing the appropriate security mechanisms to safeguard their SOAP envelopes.

### Security Policy Configuration Types

#### Inbound Security Configurations

- `TimestampTokenConfig`: Represents the record for Timestamp Token policy.
- Fields:
- `int` timeToLive : The time to get expired

- `UsernameTokenConfig`: Represents the record for Username Token policy.
- Fields:
- `string` username : The name of the user
- `string` password : The password of the user
- `PasswordType` passwordType : The password type of the username token

- `SymmetricBindingConfig`: Represents the record for Symmetric Binding policy.
- Fields:
- `crypto:PrivateKey` symmetricKey : The key to sign and encrypt the SOAP envelope
- `crypto:PublicKey` servicePublicKey : The key to encrypt the symmetric key
- `SignatureAlgorithm` signatureAlgorithm : The algorithm to sign the SOAP envelope
- `EncryptionAlgorithm` encryptionAlgorithm : The algorithm to encrypt the SOAP envelope
- `string` x509Token : The path or token of the X509 certificate

- `AsymmetricBindingConfig`: Represents the record for Username Token with Asymmetric Binding policy.
- Fields:
- `crypto:PrivateKey` signatureKey : The private key to sign the SOAP envelope
- `crypto:PublicKey` encryptionKey : The public key to encrypt the SOAP body
- `SignatureAlgorithm` signatureAlgorithm : The algorithm to sign the SOAP envelope
- `EncryptionAlgorithm` encryptionAlgorithm : The algorithm to encrypt the SOAP body
- `string` x509Token : field description

#### Outbound Security Configurations

- `OutboundSecurityConfig`: Represents the record for outbound security configurations to verify and decrypt SOAP envelopes.
- Fields:
- `crypto:PublicKey` verificationKey : The public key to verify the signature of the SOAP envelope
- `crypto:PrivateKey`|`crypto:PublicKey` decryptionKey : The private key to decrypt the SOAP envelope
- `SignatureAlgorithm` signatureAlgorithm : The algorithm to verify the SOAP envelope
- `EncryptionAlgorithm` decryptionAlgorithm : The algorithm to decrypt the SOAP body

### Apply Security Policies

#### SOAP 1.1 Client: UsernameToken and TranportBinding Policy

```ballerina
import ballerina/crypto;
import ballerina/mime;
import ballerina/soap;
import ballerina/soap:soap11;

public function main() returns error? {
soap11:Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL",
{
inboundSecurity: [
{
username: "username",
password: "password",
passwordType: soap:TEXT
},
TRANSPORT_BINDING
]
});

xml envelope = xml `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<quer:Add xmlns:quer="http://tempuri.org/">
<quer:intA>2</quer:intA>
<quer:intB>3</quer:intB>
</quer:Add>
</soap:Body>
</soap:Envelope>`;
xml|mime:Entity[] response = check soapClient->sendReceive(envelope, "http://tempuri.org/Add");
}
```

#### SOAP 1.2 Client with Asymmetric Binding and Outbound Security Configuration

```ballerina
import ballerina/crypto;
import ballerina/mime;
import ballerina/soap;
import ballerina/soap:soap12;

public function main() returns error? {
configurable crypto:PrivateKey clientPrivateKey = ?;
configurable crypto:PublicKey clientPublicKey = ?;
configurable ​crypto:PublicKey serverPublicKey = ?;

soap12:Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL",
{
inboundSecurity: {
signatureAlgorithm: soap:RSA_SHA256,
encryptionAlgorithm: soap:RSA_ECB,
signatureKey: clientPrivateKey,
encryptionKey: serverPublicKey,
},
outboundSecurity: {
verificationKey: serverPublicKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionKey: clientPrivateKey,
decryptionAlgorithm: soap:RSA_ECB
}
});

xml envelope = xml `<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<quer:Add xmlns:quer="http://tempuri.org/">
<quer:intA>2</quer:intA>
<quer:intB>3</quer:intB>
</quer:Add>
</soap:Body>
</soap:Envelope>`;
xml|mime:Entity[] response = check soapClient->sendReceive(envelope, "http://tempuri.org/Add");
}
```

## Issues and projects

Expand Down
31 changes: 31 additions & 0 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,39 @@ org = "ballerina"
name = "soap"
version = "0.2.0"
authors = ["Ballerina"]
export=["soap", "soap.soap11", "soap.soap12"]
keywords = ["soap"]
repository = "https://github.com/ballerina-platform/module-ballerina-soap"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.8.0"

[build-options]
observabilityIncluded = true

[platform.java17]
graalvmCompatible = true

[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "soap-native"
version = "0.2.0"
path = "../native/build/libs/soap-native-0.2.0-SNAPSHOT.jar"
Nuvindu marked this conversation as resolved.
Show resolved Hide resolved

[[platform.java17.dependency]]
groupId = "org.apache.wss4j"
artifactId = "wss4j-ws-security-dom"
version = "3.0.1"
path = "./lib/wss4j-ws-security-dom-3.0.1.jar"
Nuvindu marked this conversation as resolved.
Show resolved Hide resolved

[[platform.java17.dependency]]
groupId = "org.apache.wss4j"
artifactId = "wss4j-ws-security-common"
version = "3.0.1"
path = "./lib/wss4j-ws-security-common-3.0.1.jar"
Nuvindu marked this conversation as resolved.
Show resolved Hide resolved

[[platform.java17.dependency]]
groupId = "org.apache.santuario"
artifactId = "xmlsec"
version = "3.0.2"
path = "./lib/xmlsec-3.0.2.jar"
44 changes: 37 additions & 7 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.8.0-20230726-145300-b2bdf796"
distribution-version = "2201.8.0"

[[package]]
org = "ballerina"
Expand All @@ -22,7 +22,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "cache"
version = "3.7.0"
version = "3.7.1"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -46,6 +46,9 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
]
modules = [
{org = "ballerina", packageName = "crypto", moduleName = "crypto"}
]

[[package]]
org = "ballerina"
Expand All @@ -61,7 +64,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.10.0"
version = "2.10.3"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down Expand Up @@ -98,11 +101,17 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.value"}
]
modules = [
{org = "ballerina", packageName = "io", moduleName = "io"}
]

[[package]]
org = "ballerina"
name = "jballerina.java"
version = "0.0.0"
modules = [
{org = "ballerina", packageName = "jballerina.java", moduleName = "jballerina.java"}
]

[[package]]
org = "ballerina"
Expand Down Expand Up @@ -148,7 +157,6 @@ dependencies = [
org = "ballerina"
name = "lang.error"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand All @@ -175,6 +183,9 @@ version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
modules = [
{org = "ballerina", packageName = "lang.regexp", moduleName = "lang.regexp"}
]

[[package]]
org = "ballerina"
Expand Down Expand Up @@ -260,12 +271,20 @@ org = "ballerina"
name = "soap"
version = "0.2.0"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "http"},
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.regexp"},
{org = "ballerina", name = "mime"},
{org = "ballerina", name = "test"}
{org = "ballerina", name = "test"},
{org = "ballerinai", name = "observe"}
]
modules = [
{org = "ballerina", packageName = "soap", moduleName = "soap"}
{org = "ballerina", packageName = "soap", moduleName = "soap"},
{org = "ballerina", packageName = "soap", moduleName = "soap.soap11"},
{org = "ballerina", packageName = "soap", moduleName = "soap.soap12"},
{org = "ballerina", packageName = "soap", moduleName = "soap.wssec"}
]

[[package]]
Expand All @@ -281,7 +300,6 @@ dependencies = [
org = "ballerina"
name = "test"
version = "0.0.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.error"}
Expand All @@ -306,3 +324,15 @@ dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerinai"
name = "observe"
version = "0.0.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "observe"}
]
modules = [
{org = "ballerinai", packageName = "observe", moduleName = "observe"}
]

Loading