Skip to content

Commit

Permalink
Merge pull request #5826 from Nuvindu/java21-soap-fix
Browse files Browse the repository at this point in the history
Fix build failures in SOAP examples
  • Loading branch information
Nuvindu authored Nov 18, 2024
2 parents 35153d6 + 37890a4 commit 2bb00b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import ballerina/soap;
import ballerina/soap.soap12;

public function main() returns error? {
crypto:KeyStore keyStore = {
path: "/path/to/keyStore.p12",
password: "keyStorePassword"
};
crypto:KeyStore decryptionKeyStore = {
path: "/path/to/keyStore.p12",
password: "keyStorePassword"
};

soap12:Client soapClient = check new ("http://soap-endpoint.com?wsdl",
{
inboundSecurity: {
username: "user",
password: "password",
passwordType: soap:TEXT
signatureKeystore: keyStore,
decryptKeystore: decryptionKeyStore
}
}
);

xml body = xml `<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body></soap:Body>
</soap:Envelope>`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import ballerina/crypto;
import ballerina/soap;
import ballerina/soap.soap12;

public function main() returns error? {
crypto:PrivateKey verificationKey = check crypto:decodeRsaPrivateKeyFromKeyFile(
"../resource/path/to/private.key"
);
crypto:PublicKey decryptionKey = check crypto:decodeRsaPublicKeyFromCertFile(
"../resource/path/to/public.crt"
);
crypto:KeyStore keyStore = {
path: "/path/to/keyStore.p12",
password: "keyStorePassword"
};
crypto:KeyStore decryptionKeyStore = {
path: "/path/to/decryptionKeyStore.p12",
password: "keyStorePassword"
};

soap12:Client soapClient = check new ("http://soap-endpoint.com?wsdl",
{
outboundSecurity: {
verificationKey: verificationKey,
signatureAlgorithm: soap:RSA_SHA256,
decryptionKey: decryptionKey,
decryptionAlgorithm: soap:RSA_ECB
signatureConfig: {
keystore: keyStore,
privateKeyAlias: "private-key-alias",
privateKeyPassword: "private-key-password"
},
encryptionConfig: {
keystore: decryptionKeyStore,
publicKeyAlias: "public-key-alias"
}
}
}
);

xml body = xml `<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body></soap:Body>
</soap:Envelope>`;
Expand Down

0 comments on commit 2bb00b9

Please sign in to comment.