Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* Copyright 2026 predic8 GmbH, www.predic8.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

package com.predic8.membrane.tutorials.soap;

import org.junit.jupiter.api.*;

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

public class RoutingBySOAPActionTutorialTest extends AbstractSOAPTutorialTest {

@Override
protected String getTutorialYaml() {
return "75-Routing-by-SOAPAction.yaml";
}

@Test
void routesToGetCityBySOAPAction() {
// @formatter:off
given()
.header("SOAPAction", "https://predic8.de/city-service/get")
.when()
.post("http://localhost:2000")
.then()
.statusCode(200)
.body(equalTo("getCity"));
// @formatter:on
}

@Test
void routesToCreateCityBySOAPAction() {
// @formatter:off
given()
.header("SOAPAction", "https://predic8.de/city-service/create")
.when()
.post("http://localhost:2000")
.then()
.statusCode(200)
.body(equalTo("createCity"));
// @formatter:on
}

@Test
void fallbackRouteForUnknownSOAPAction() {
// @formatter:off
given()
.header("SOAPAction", "https://predic8.de/city-service/unknown")
.when()
.post("http://localhost:2000")
.then()
.statusCode(404);
// @formatter:on
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/* Copyright 2026 predic8 GmbH, www.predic8.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

package com.predic8.membrane.tutorials.soap;

import org.junit.jupiter.api.*;

import java.io.*;

import static io.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;

public class RoutingByWrapperElementTutorialTest extends AbstractSOAPTutorialTest {

@Override
protected String getTutorialYaml() {
return "70-Routing-by-Wrapper-Element.yaml";
}

@Test
void routesToGetCityByWrapperElement() throws IOException {
// @formatter:off
given()
.contentType("text/xml")
.body(readFileFromBaseDir("city.soap.xml"))
.when()
.post("http://localhost:2000")
.then()
.statusCode(200)
.body(equalTo("getCity"));
// @formatter:on
}

@Test
void fallbackRouteForNonMatchingBody() {
// @formatter:off
given()
.contentType("text/xml")
.body("<s11:Envelope xmlns:s11=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<s11:Body><unknown/></s11:Body>"
+ "</s11:Envelope>")
.when()
.post("http://localhost:2000")
.then()
.statusCode(404);
// @formatter:on
}

@Test
void fallbackRouteWithoutBody() {
// @formatter:off
given()
.when()
.post("http://localhost:2000")
.then()
.statusCode(404);
// @formatter:on
}
}
38 changes: 38 additions & 0 deletions distribution/tutorials/soap/70-Routing-by-Wrapper-Element.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# yaml-language-server: $schema=https://www.membrane-api.io/v7.1.0.json
#
# Tutorial: SOAP Routing by Wrapper Element
#
# Routes SOAP requests by inspecting the wrapper element inside the SOAP Body.
# Some SOAP stacks route using the SOAPAction header instead
# (see 75-Routing-by-SOAPAction.yaml).
#
# Try:
# curl localhost:2000
# curl localhost:2000 -H "Content-Type: text/xml" -d @city.soap.xml -v

components:
ns:
xmlConfig:
namespaces:
- prefix: c
uri: https://predic8.de/cities

---
api:
port: 2000
test: //c:getCity
language: xpath
flow:
- setBody:
value: getCity
- return:
status: 200

---
api:
port: 2000
flow:
- log:
message: "Missed!"
- return:
status: 404
42 changes: 42 additions & 0 deletions distribution/tutorials/soap/75-Routing-by-SOAPAction.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# yaml-language-server: $schema=https://www.membrane-api.io/v7.1.0.json
#
# Tutorial: SOAP Routing by SOAPAction
#
# Routes SOAP requests based on the SOAPAction header.
# A more common approach is routing by the SOAPBody child element
# (see sample 70-Routing-by-Wrapper-Element.yaml).
#
# Try:
# curl localhost:2000 -H "SOAPAction: https://predic8.de/city-service/get"
# curl localhost:2000 -H "SOAPAction: https://predic8.de/city-service/create"
#
# Notes:
# - Some SOAP stacks send SOAPAction with quotes, e.g. "https://.../get"

api:
port: 2000
test: header.SOAPAction == 'https://predic8.de/city-service/get'
flow:
- setBody:
value: getCity
- return:
status: 200

---
api:
port: 2000
test: header.SOAPAction == 'https://predic8.de/city-service/create'
flow:
- setBody:
value: createCity
- return:
status: 200

---
api:
port: 2000
flow:
- log:
message: "Not supported: ${header.SOAPAction}"
- return:
status: 404
Loading