diff --git a/ballerina/modules/soap12/tests/http_soap_service.bal b/ballerina/modules/soap12/tests/http_soap_service.bal index 448257b..162544c 100644 --- a/ballerina/modules/soap12/tests/http_soap_service.bal +++ b/ballerina/modules/soap12/tests/http_soap_service.bal @@ -66,6 +66,12 @@ service / on new http:Listener(9090) { at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)`; } + resource function post getErrorPayload(http:Request request) returns xml|http:InternalServerError { + return { + body: "Error occurred in the server" + }; + } + resource function post getSamePayload(http:Request request) returns xml|error { return check request.getXmlPayload(); } diff --git a/ballerina/modules/soap12/tests/soap12_client_test.bal b/ballerina/modules/soap12/tests/soap12_client_test.bal index 8cfebf0..21f50f8 100644 --- a/ballerina/modules/soap12/tests/soap12_client_test.bal +++ b/ballerina/modules/soap12/tests/soap12_client_test.bal @@ -99,6 +99,18 @@ function testSendReceive12WithAction() returns error? { test:assertEquals(response, expected); } +@test:Config { + groups: ["soap12", "send_receive"] +} +function testSendReceive12WithServerError() returns error? { + Client soapClient = check new ("http://localhost:9090"); + xml body = xml `23`; + + xml|Error response = soapClient->sendReceive(body, path = "/getErrorPayload"); + test:assertTrue(response is Error); + test:assertEquals((((response).cause()).cause()).message(), "Internal Server Error"); +} + @test:Config { groups: ["soap12", "send_receive"] } @@ -347,26 +359,6 @@ function testSendReceiveError() returns error? { test:assertEquals((response).message(), SOAP_ERROR); } -@test:Config { - groups: ["soap12", "send_receive"] -} -function testSendReceiveWithInvalidAction() returns error? { - Client soapClient = check new ("http://www.dneonline.com/invalidcalculator.asmx?WSDL"); - xml body = xml ` - - - 2 - 3 - - - `; - xml|Error response = soapClient->sendReceive(body, "http://tempuri.org/invalid_action"); - test:assertTrue(response is Error); - test:assertEquals((response).message(), SOAP_ERROR); -} - @test:Config { groups: ["soap12", "send_receive"] }