From 1cb6037fb9309b99d769801f808b57caaf227f53 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Thu, 30 Nov 2023 22:35:30 +0530 Subject: [PATCH 01/11] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 6 +++--- ballerina/Dependencies.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index b6306cd..719296c 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "soap" -version = "0.9.0" +version = "0.9.1" authors = ["Ballerina"] export=["soap", "soap.soap11", "soap.soap12"] keywords = ["soap"] @@ -19,8 +19,8 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "soap-native" -version = "0.9.0" -path = "../native/build/libs/soap-native-0.9.0.jar" +version = "0.9.1" +path = "../native/build/libs/soap-native-0.9.1-SNAPSHOT.jar" [[platform.java17.dependency]] groupId = "org.apache.wss4j" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 1ed4692..fc5e90a 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -64,7 +64,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.10.1" +version = "2.10.4" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -269,7 +269,7 @@ dependencies = [ [[package]] org = "ballerina" name = "soap" -version = "0.9.0" +version = "0.9.1" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "http"}, From ee0bb1c4f49cabc1a3908e1976713213be018c43 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Thu, 30 Nov 2023 22:36:03 +0530 Subject: [PATCH 02/11] Fix action header in the SOAP 1.2 version --- ballerina/soap_utils.bal | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ballerina/soap_utils.bal b/ballerina/soap_utils.bal index 0e36532..868a18a 100644 --- a/ballerina/soap_utils.bal +++ b/ballerina/soap_utils.bal @@ -150,16 +150,20 @@ isolated function createSoap11HttpRequest(xml|mime:Entity[] body, string soapAct isolated function createSoap12HttpRequest(xml|mime:Entity[] body, string? soapAction, map headers = {}) returns http:Request { http:Request req = new; - if body is xml { - req.setXmlPayload(body); + _ = body is xml ? req.setXmlPayload(body) : req.setBodyParts(body); + if soapAction is string { + map stringMap = {}; + stringMap["action"] = "\"" + soapAction + "\""; + var mediaType = mime:getMediaType(mime:APPLICATION_SOAP_XML); + if mediaType is mime:MediaType { + mediaType.parameters = stringMap; + req.addHeader(mime:CONTENT_TYPE, mediaType.toString()); + } + } else if body is xml { req.setHeader(mime:CONTENT_TYPE, mime:TEXT_XML); } else { - req.setBodyParts(body); req.setHeader(mime:CONTENT_TYPE, mime:MULTIPART_MIXED); } - if soapAction is string { - req.addHeader(SOAP_ACTION, soapAction); - } foreach string key in headers.keys() { req.addHeader(key, headers[key].toBalString()); } From 2cd43afb85b038ca65bda2fd81a0cb6e6bec7e1d Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Thu, 30 Nov 2023 22:36:17 +0530 Subject: [PATCH 03/11] Modify test cases to validate the new fix --- .../soap12/tests/http_soap_service.bal | 14 +++ .../soap12/tests/soap12_client_test.bal | 92 ++++++------------- 2 files changed, 44 insertions(+), 62 deletions(-) diff --git a/ballerina/modules/soap12/tests/http_soap_service.bal b/ballerina/modules/soap12/tests/http_soap_service.bal index f4cc2bd..e86983a 100644 --- a/ballerina/modules/soap12/tests/http_soap_service.bal +++ b/ballerina/modules/soap12/tests/http_soap_service.bal @@ -48,6 +48,20 @@ service / on new http:Listener(9090) { return response; } + resource function post getActionPayload(http:Request request) returns http:Response|error { + string[] headers = check request.getHeaders(mime:CONTENT_TYPE); + mime:MediaType mediaHeader = check mime:getMediaType(headers[1]); + map actionMap = mediaHeader.parameters; + string action = actionMap.get("action"); + if action == "http://tempuri.org/Add" { + xml payload = check request.getXmlPayload(); + http:Response response = new; + response.setPayload(payload); + return response; + } + return error("Invalid action is found"); + } + resource function post getSamePayload(http:Request request) returns http:Response|error { xml payload = check request.getXmlPayload(); http:Response response = new; diff --git a/ballerina/modules/soap12/tests/soap12_client_test.bal b/ballerina/modules/soap12/tests/soap12_client_test.bal index 331848f..107565b 100644 --- a/ballerina/modules/soap12/tests/soap12_client_test.bal +++ b/ballerina/modules/soap12/tests/soap12_client_test.bal @@ -87,6 +87,18 @@ function testSendOnlyError12() returns error? { test:assertTrue(response is Error); } +@test:Config { + groups: ["soap12", "send_receive", "ww"] +} +function testSendReceive12WithAction() returns error? { + Client soapClient = check new ("http://localhost:9090"); + xml body = xml `23`; + + xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add", path = "/getActionPayload"); + xml expected = xml `23`; + test:assertEquals(response, expected); +} + @test:Config { groups: ["soap12", "send_receive"] } @@ -102,7 +114,7 @@ function testSendReceive12() returns error? { `; - xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add"); + xml response = check soapClient->sendReceive(body); xml expected = xml `5`; test:assertEquals(response, expected); @@ -203,31 +215,7 @@ function testSendReceive12WithHeaders() returns error? { Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL"); - xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add", - {foo: ["bar1", "bar2"]}); - - xml expected = xml `5`; - test:assertEquals(response, expected); -} - -@test:Config { - groups: ["soap12", "send_receive"] -} -function testSendReceive12WithoutSoapAction() returns error? { - xml body = xml ` - - - 2 - 3 - - - `; - - Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL"); - - xml response = check soapClient->sendReceive(body); + xml response = check soapClient->sendReceive(body, headers = {foo: ["bar1", "bar2"]}); xml expected = xml `5`; test:assertEquals(response, expected); @@ -253,28 +241,6 @@ function testSendOnly12WithoutSoapAction() returns error? { check soapClient->sendOnly(body); } -@test:Config { - groups: ["soap12", "send_receive"] -} -function testSendReceive12IncludingHeadersWithoutSoapAction() returns error? { - xml body = xml ` - - - 2 - 3 - - - `; - - Client soapClient = check new ("http://www.dneonline.com/calculator.asmx?WSDL"); - - xml response = check soapClient->sendReceive(body, (), {foo: ["bar1", "bar2"]}); - xml expected = xml `5`; - test:assertEquals(response, expected); -} - @test:Config { groups: ["soap12"] } @@ -340,7 +306,7 @@ function testSendReceiveWithTimestampTokenSecurity() returns error? { `; - xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add"); + xml response = check soapClient->sendReceive(body); xml expected = xml `soap:MustUnderstandSystem.Web.Services.Protocols.SoapHeaderException: SOAP header Security was not understood. at System.Web.Services.Protocols.SoapHeaderHandling.SetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client) at System.Web.Services.Protocols.SoapServerProtocol.CreateServerInstance() @@ -374,7 +340,7 @@ function testSendReceiveWithUsernameTokenSecurity() returns error? { `; - xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add"); + xml response = check soapClient->sendReceive(body); xml expected = xml `soap:MustUnderstandSystem.Web.Services.Protocols.SoapHeaderException: SOAP header Security was not understood. at System.Web.Services.Protocols.SoapHeaderHandling.SetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client) at System.Web.Services.Protocols.SoapServerProtocol.CreateServerInstance() @@ -421,12 +387,13 @@ function testSendReceiveWithAsymmetricBindingSecurity() returns error? { `; - xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add"); - xml expected = xml `soap:MustUnderstandSystem.Web.Services.Protocols.SoapHeaderException: SOAP header Security was not understood. - at System.Web.Services.Protocols.SoapHeaderHandling.SetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client) - at System.Web.Services.Protocols.SoapServerProtocol.CreateServerInstance() - at System.Web.Services.Protocols.WebServiceHandler.Invoke() - at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()`; + xml response = check soapClient->sendReceive(body); + xml expected = xml `soap:SenderSystem.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action. + at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() + at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) + at System.Web.Services.Protocols.SoapServerProtocol.Initialize() + at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) + at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)`; test:assertEquals(response.toString(), expected.toString()); } @@ -467,12 +434,13 @@ function testSendReceiveWithSymmetricBindingSecurity() returns error? { `; - xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add"); - xml expected = xml `soap:MustUnderstandSystem.Web.Services.Protocols.SoapHeaderException: SOAP header Security was not understood. - at System.Web.Services.Protocols.SoapHeaderHandling.SetHeaderMembers(SoapHeaderCollection headers, Object target, SoapHeaderMapping[] mappings, SoapHeaderDirection direction, Boolean client) - at System.Web.Services.Protocols.SoapServerProtocol.CreateServerInstance() - at System.Web.Services.Protocols.WebServiceHandler.Invoke() - at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()`; + xml response = check soapClient->sendReceive(body); + xml expected = xml `soap:SenderSystem.Web.Services.Protocols.SoapException: Unable to handle request without a valid action parameter. Please supply a valid soap action. + at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() + at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message) + at System.Web.Services.Protocols.SoapServerProtocol.Initialize() + at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response) + at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)`; test:assertEquals(response.toString(), expected.toString()); } From 703e5bbc039b4c7ec5d486e287916837506d7f7e Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Fri, 1 Dec 2023 10:01:35 +0530 Subject: [PATCH 04/11] Apply suggestions from the review --- ballerina/modules/soap12/tests/http_soap_service.bal | 4 ++-- ballerina/soap_utils.bal | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ballerina/modules/soap12/tests/http_soap_service.bal b/ballerina/modules/soap12/tests/http_soap_service.bal index e86983a..3bce134 100644 --- a/ballerina/modules/soap12/tests/http_soap_service.bal +++ b/ballerina/modules/soap12/tests/http_soap_service.bal @@ -24,7 +24,7 @@ const crypto:KeyStore serverKeyStore = { password: KEY_PASSWORD }; crypto:PrivateKey serverPrivateKey = check crypto:decodeRsaPrivateKeyFromKeyStore(serverKeyStore, KEY_ALIAS, - KEY_PASSWORD); + KEY_PASSWORD); crypto:PublicKey serverPublicKey = check crypto:decodeRsaPublicKeyFromTrustStore(serverKeyStore, KEY_ALIAS); service / on new http:Listener(9090) { @@ -50,7 +50,7 @@ service / on new http:Listener(9090) { resource function post getActionPayload(http:Request request) returns http:Response|error { string[] headers = check request.getHeaders(mime:CONTENT_TYPE); - mime:MediaType mediaHeader = check mime:getMediaType(headers[1]); + mime:MediaType mediaHeader = check mime:getMediaType(headers[0]); map actionMap = mediaHeader.parameters; string action = actionMap.get("action"); if action == "http://tempuri.org/Add" { diff --git a/ballerina/soap_utils.bal b/ballerina/soap_utils.bal index 868a18a..00c720a 100644 --- a/ballerina/soap_utils.bal +++ b/ballerina/soap_utils.bal @@ -152,12 +152,10 @@ isolated function createSoap12HttpRequest(xml|mime:Entity[] body, string? soapAc http:Request req = new; _ = body is xml ? req.setXmlPayload(body) : req.setBodyParts(body); if soapAction is string { - map stringMap = {}; - stringMap["action"] = "\"" + soapAction + "\""; var mediaType = mime:getMediaType(mime:APPLICATION_SOAP_XML); if mediaType is mime:MediaType { - mediaType.parameters = stringMap; - req.addHeader(mime:CONTENT_TYPE, mediaType.toString()); + mediaType.parameters = {"action": string`"${soapAction}"`}; + req.setHeader(mime:CONTENT_TYPE, mediaType.toString()); } } else if body is xml { req.setHeader(mime:CONTENT_TYPE, mime:TEXT_XML); From 1ab5456177af6b913487412fa39101b29cf7e1e0 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Fri, 1 Dec 2023 10:57:25 +0530 Subject: [PATCH 05/11] Apply suggestions from the review --- ballerina/modules/soap12/tests/http_soap_service.bal | 2 +- ballerina/modules/soap12/tests/soap12_client_test.bal | 2 +- ballerina/soap_utils.bal | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ballerina/modules/soap12/tests/http_soap_service.bal b/ballerina/modules/soap12/tests/http_soap_service.bal index 3bce134..f57e4fc 100644 --- a/ballerina/modules/soap12/tests/http_soap_service.bal +++ b/ballerina/modules/soap12/tests/http_soap_service.bal @@ -50,7 +50,7 @@ service / on new http:Listener(9090) { resource function post getActionPayload(http:Request request) returns http:Response|error { string[] headers = check request.getHeaders(mime:CONTENT_TYPE); - mime:MediaType mediaHeader = check mime:getMediaType(headers[0]); + mime:MediaType mediaHeader = check mime:getMediaType(headers[1]); map actionMap = mediaHeader.parameters; string action = actionMap.get("action"); if action == "http://tempuri.org/Add" { diff --git a/ballerina/modules/soap12/tests/soap12_client_test.bal b/ballerina/modules/soap12/tests/soap12_client_test.bal index 107565b..6121e61 100644 --- a/ballerina/modules/soap12/tests/soap12_client_test.bal +++ b/ballerina/modules/soap12/tests/soap12_client_test.bal @@ -88,7 +88,7 @@ function testSendOnlyError12() returns error? { } @test:Config { - groups: ["soap12", "send_receive", "ww"] + groups: ["soap12", "send_receive"] } function testSendReceive12WithAction() returns error? { Client soapClient = check new ("http://localhost:9090"); diff --git a/ballerina/soap_utils.bal b/ballerina/soap_utils.bal index 00c720a..b34c367 100644 --- a/ballerina/soap_utils.bal +++ b/ballerina/soap_utils.bal @@ -152,10 +152,12 @@ isolated function createSoap12HttpRequest(xml|mime:Entity[] body, string? soapAc http:Request req = new; _ = body is xml ? req.setXmlPayload(body) : req.setBodyParts(body); if soapAction is string { + map stringMap = {}; + stringMap["action"] = "\"" + soapAction + "\""; var mediaType = mime:getMediaType(mime:APPLICATION_SOAP_XML); if mediaType is mime:MediaType { mediaType.parameters = {"action": string`"${soapAction}"`}; - req.setHeader(mime:CONTENT_TYPE, mediaType.toString()); + req.addHeader(mime:CONTENT_TYPE, mediaType.toString()); } } else if body is xml { req.setHeader(mime:CONTENT_TYPE, mime:TEXT_XML); From 56d25d9cdbad8c5c8fc1aa9e552be73f03af218e Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Fri, 1 Dec 2023 11:50:20 +0530 Subject: [PATCH 06/11] Fix 'content-type' header in mime requests --- .../modules/soap12/tests/http_soap_service.bal | 2 +- .../modules/soap12/tests/soap12_client_test.bal | 6 +++--- ballerina/soap_utils.bal | 13 +++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ballerina/modules/soap12/tests/http_soap_service.bal b/ballerina/modules/soap12/tests/http_soap_service.bal index f57e4fc..3bce134 100644 --- a/ballerina/modules/soap12/tests/http_soap_service.bal +++ b/ballerina/modules/soap12/tests/http_soap_service.bal @@ -50,7 +50,7 @@ service / on new http:Listener(9090) { resource function post getActionPayload(http:Request request) returns http:Response|error { string[] headers = check request.getHeaders(mime:CONTENT_TYPE); - mime:MediaType mediaHeader = check mime:getMediaType(headers[1]); + mime:MediaType mediaHeader = check mime:getMediaType(headers[0]); map actionMap = mediaHeader.parameters; string action = actionMap.get("action"); if action == "http://tempuri.org/Add" { diff --git a/ballerina/modules/soap12/tests/soap12_client_test.bal b/ballerina/modules/soap12/tests/soap12_client_test.bal index 6121e61..a3443ac 100644 --- a/ballerina/modules/soap12/tests/soap12_client_test.bal +++ b/ballerina/modules/soap12/tests/soap12_client_test.bal @@ -121,7 +121,7 @@ function testSendReceive12() returns error? { } @test:Config { - groups: ["soap12", "send_receive"] + groups: ["soap12", "send_receive", "mime"] } function testSendReceive12Mime() returns error? { Client soapClient = check new ("http://localhost:9090"); @@ -485,7 +485,7 @@ function testSoapReceiveWithSymmetricBindingAndOutboundConfig() returns error? { } ); xml body = xml `23`; - xml|mime:Entity[] response = check soapClient->sendReceive(body, "http://tempuri.org/Add", path = "/getSamePayload"); + xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add", path = "/getSamePayload"); return soap:assertSymmetricBinding(response.toString(), string `23`); } @@ -511,7 +511,7 @@ function testSendReceiveWithAsymmetricBindingAndOutboundConfig() returns error? ); xml body = xml `23`; - xml|mime:Entity[] response = check soapClient->sendReceive(body, "http://tempuri.org/Add", path = "/getSecuredPayload"); + xml response = check soapClient->sendReceive(body, "http://tempuri.org/Add", path = "/getSecuredPayload"); return soap:assertSymmetricBinding(response.toString(), string `23`); } diff --git a/ballerina/soap_utils.bal b/ballerina/soap_utils.bal index b34c367..c069fd9 100644 --- a/ballerina/soap_utils.bal +++ b/ballerina/soap_utils.bal @@ -154,15 +154,16 @@ isolated function createSoap12HttpRequest(xml|mime:Entity[] body, string? soapAc if soapAction is string { map stringMap = {}; stringMap["action"] = "\"" + soapAction + "\""; - var mediaType = mime:getMediaType(mime:APPLICATION_SOAP_XML); + mime:MediaType|mime:InvalidContentTypeError mediaType = body is xml + ? mime:getMediaType(mime:APPLICATION_SOAP_XML) + : mime:getMediaType(mime:MULTIPART_MIXED); if mediaType is mime:MediaType { - mediaType.parameters = {"action": string`"${soapAction}"`}; - req.addHeader(mime:CONTENT_TYPE, mediaType.toString()); + mediaType.parameters = {"action": string `"${soapAction}"`}; + req.setHeader(mime:CONTENT_TYPE, mediaType.toString()); } - } else if body is xml { - req.setHeader(mime:CONTENT_TYPE, mime:TEXT_XML); } else { - req.setHeader(mime:CONTENT_TYPE, mime:MULTIPART_MIXED); + _ = body is xml ? req.setHeader(mime:CONTENT_TYPE, mime:TEXT_XML) + : req.setHeader(mime:CONTENT_TYPE, mime:MULTIPART_MIXED); } foreach string key in headers.keys() { req.addHeader(key, headers[key].toBalString()); From c396b2c18eb486eccda35da5873b8b42d750bf53 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Fri, 1 Dec 2023 11:59:43 +0530 Subject: [PATCH 07/11] Add test case to validate mime requests without action --- .../soap12/tests/soap12_client_test.bal | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ballerina/modules/soap12/tests/soap12_client_test.bal b/ballerina/modules/soap12/tests/soap12_client_test.bal index a3443ac..42334b7 100644 --- a/ballerina/modules/soap12/tests/soap12_client_test.bal +++ b/ballerina/modules/soap12/tests/soap12_client_test.bal @@ -198,6 +198,45 @@ function testSendReceive12WithMime2() returns error? { test:assertEquals(response, body); } +@test:Config { + groups: ["soap12", "send_receive", "mime", "h"] +} +function testSendReceive12MimeWithoutAction() returns error? { + Client soapClient = check new ("http://localhost:9090"); + xml body = xml ` + + + 2 + 3 + + + `; + + mime:Entity[] mtomMessage = []; + mime:Entity envelope = new; + check envelope.setContentType("application/xop+xml"); + envelope.setContentId(""); + envelope.setBody(body); + mtomMessage.push(envelope); + + mime:Entity bytesPart = new; + string readContent = check io:fileReadString(FILE_PATH); + bytesPart.setFileAsEntityBody(FILE_PATH); + string|byte[]|io:ReadableByteChannel|mime:EncodeError bytes = mime:base64Encode(readContent.toBytes()); + if bytes !is byte[] { + return error("error"); + } + bytesPart.setBody(bytes); + check bytesPart.setContentType("image/jpeg"); + bytesPart.setContentId(""); + mtomMessage.push(bytesPart); + + mime:Entity[] response = check soapClient->sendReceive(mtomMessage, path = "/getMimePayload"); + test:assertEquals(response[0].getXml(), check mtomMessage[0].getXml()); +} + @test:Config { groups: ["soap12", "send_receive"] } From 59cda05a2ddbe0b4f2a89a79bd6085e3ff839e77 Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Sat, 2 Dec 2023 20:09:46 +0530 Subject: [PATCH 08/11] Replace ternary expressions with if-else conditions --- ballerina/soap_utils.bal | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ballerina/soap_utils.bal b/ballerina/soap_utils.bal index c069fd9..7e4f05f 100644 --- a/ballerina/soap_utils.bal +++ b/ballerina/soap_utils.bal @@ -150,20 +150,28 @@ isolated function createSoap11HttpRequest(xml|mime:Entity[] body, string soapAct isolated function createSoap12HttpRequest(xml|mime:Entity[] body, string? soapAction, map headers = {}) returns http:Request { http:Request req = new; - _ = body is xml ? req.setXmlPayload(body) : req.setBodyParts(body); + if body is xml { + req.setXmlPayload(body); + } else { + req.setBodyParts(body); + } if soapAction is string { map stringMap = {}; stringMap["action"] = "\"" + soapAction + "\""; - mime:MediaType|mime:InvalidContentTypeError mediaType = body is xml - ? mime:getMediaType(mime:APPLICATION_SOAP_XML) - : mime:getMediaType(mime:MULTIPART_MIXED); + mime:MediaType|mime:InvalidContentTypeError mediaType; + if body is xml { + mediaType = mime:getMediaType(mime:APPLICATION_SOAP_XML); + } else { + mediaType = mime:getMediaType(mime:MULTIPART_MIXED); + } if mediaType is mime:MediaType { mediaType.parameters = {"action": string `"${soapAction}"`}; req.setHeader(mime:CONTENT_TYPE, mediaType.toString()); } + } else if body is xml { + req.setHeader(mime:CONTENT_TYPE, mime:TEXT_XML); } else { - _ = body is xml ? req.setHeader(mime:CONTENT_TYPE, mime:TEXT_XML) - : req.setHeader(mime:CONTENT_TYPE, mime:MULTIPART_MIXED); + req.setHeader(mime:CONTENT_TYPE, mime:MULTIPART_MIXED); } foreach string key in headers.keys() { req.addHeader(key, headers[key].toBalString()); From 5a594335db790ef5ffd8d7f13a60e5148f3e511e Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Mon, 4 Dec 2023 10:14:14 +0530 Subject: [PATCH 09/11] Remove unnecessary lines of code --- ballerina/soap_utils.bal | 2 -- 1 file changed, 2 deletions(-) diff --git a/ballerina/soap_utils.bal b/ballerina/soap_utils.bal index 7e4f05f..e0dc49e 100644 --- a/ballerina/soap_utils.bal +++ b/ballerina/soap_utils.bal @@ -156,8 +156,6 @@ isolated function createSoap12HttpRequest(xml|mime:Entity[] body, string? soapAc req.setBodyParts(body); } if soapAction is string { - map stringMap = {}; - stringMap["action"] = "\"" + soapAction + "\""; mime:MediaType|mime:InvalidContentTypeError mediaType; if body is xml { mediaType = mime:getMediaType(mime:APPLICATION_SOAP_XML); From 3cd0aeb9d11c18fa0debf61d8d158c8a7c8b799e Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Tue, 5 Dec 2023 15:07:31 +0530 Subject: [PATCH 10/11] [Automated] Update the native jar versions --- ballerina/Ballerina.toml | 6 +++--- ballerina/Dependencies.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 719296c..543f588 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "soap" -version = "0.9.1" +version = "0.10.0" authors = ["Ballerina"] export=["soap", "soap.soap11", "soap.soap12"] keywords = ["soap"] @@ -19,8 +19,8 @@ graalvmCompatible = true [[platform.java17.dependency]] groupId = "io.ballerina.stdlib" artifactId = "soap-native" -version = "0.9.1" -path = "../native/build/libs/soap-native-0.9.1-SNAPSHOT.jar" +version = "0.10.0" +path = "../native/build/libs/soap-native-0.10.0-SNAPSHOT.jar" [[platform.java17.dependency]] groupId = "org.apache.wss4j" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index fc5e90a..1944db6 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -269,7 +269,7 @@ dependencies = [ [[package]] org = "ballerina" name = "soap" -version = "0.9.1" +version = "0.10.0" dependencies = [ {org = "ballerina", name = "crypto"}, {org = "ballerina", name = "http"}, From f1b29579aa254281eb7668c4226dcd88e81b540a Mon Sep 17 00:00:00 2001 From: Nuvindu Date: Tue, 5 Dec 2023 15:08:26 +0530 Subject: [PATCH 11/11] Bump the package version to 0.10.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 95178f8..350f148 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ org.gradle.caching=true group=io.ballerina.stdlib -version=0.9.1-SNAPSHOT +version=0.10.0-SNAPSHOT checkstylePluginVersion=10.12.0 spotbugsPluginVersion=5.0.14