0

I am making a restful web service, Service A, that in turn makes a call to another rest service, Service B. Service B is an external resource that is packaged as a war archive. This service contains a regular switchyard file in WEB-INF/switchyard.xml. Sadly, the properties in the switchyard file are rather static, i.e proxy settings, that interfere with my testing. What I would like to do is edit the switchyard.xml file, and remove sections to accommodate unnecessary proxy settings.

Here is how I am creating the deployable for Service B:

@Deployment(name = "my-service", order = 1, testable = false)
public static Archive<?> svcMyDeployable() {
    final File file = Maven.configureResolver().fromFile(System.getProperty("settings.xml"))
            .loadPomFromFile("pom.xml").resolve("com.sample.service:cool-service:war:?")
            .withoutTransitivity().asSingleFile();
    final WebArchive war = ShrinkWrap.createFromZipFile(WebArchive.class, file);
    final WebArchive archive = ShrinkWrap.create(WebArchive.class, "cool-service.war").merge(war);
    return archive;
}

The only way that I can think of overriding the properties of the switchyard.xml file in Service B, is by replacing the WEB-INF/switchyard.xml with a custom one. I can do so as follows:

archive.delete("/WEB-INF/switchyard.xml");
archive.addAsWebInfResource("custom-switchyard/switchyard.xml");

Is there a better way to accomplish this? All that I really need to do is remove 6 lines from the original switchyard.xml file:

<http:proxy>
    <http:host>10.10.10.10</http:host>
    <http:port>9999</http:port>
    <http:user>username</http:user>
    <http:password>password</http:password>
</http:proxy>
angryip
  • 2,140
  • 5
  • 33
  • 67

0 Answers0