Search in sources :

Example 1 with Schemas

use of com.predic8.membrane.annot.generator.Schemas in project service-proxy by membrane.

the class WSDLValidator method getSchemas.

@Override
protected List<Schema> getSchemas() {
    WSDLParserContext ctx = new WSDLParserContext();
    ctx.setInput(location);
    try {
        WSDLParser wsdlParser = new WSDLParser();
        // System.out.println("Resolver----" + resourceResolver);
        wsdlParser.setResourceResolver(resourceResolver.toExternalResolver().toExternalResolver());
        List<Schema> schemaList = new ArrayList<Schema>();
        for (Types t : wsdlParser.parse(ctx).getTypes()) schemaList.addAll(t.getSchemas());
        return schemaList;
    } catch (RuntimeException e) {
        throw new IllegalArgumentException("Could not download the WSDL " + location + " or its dependent XML Schemas.", e);
    }
}
Also used : Types(com.predic8.wsdl.Types) Schema(com.predic8.schema.Schema) ArrayList(java.util.ArrayList) WSDLParser(com.predic8.wsdl.WSDLParser) WSDLParserContext(com.predic8.wsdl.WSDLParserContext)

Example 2 with Schemas

use of com.predic8.membrane.annot.generator.Schemas in project service-proxy by membrane.

the class QuickstartSOAPTest method doit.

@Test
public void doit() throws IOException, InterruptedException {
    File baseDir = getExampleDir("quickstart-soap");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        ProxiesXmlUtil pxu = new ProxiesXmlUtil(new File(baseDir, "proxies.xml"));
        pxu.updateWith("<spring:beans xmlns=\"http://membrane-soa.org/proxies/1/\"\r\n" + "	xmlns:spring=\"http://www.springframework.org/schema/beans\"\r\n" + "	xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + "	xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd\r\n" + "					    http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd\">\r\n" + "\r\n" + "	<router>\r\n" + "	\r\n" + "	<soapProxy port=\"2000\" wsdl=\"http://www.thomas-bayer.com/axis2/services/BLZService?wsdl\">\r\n" + "		<path>/MyBLZService</path>\r\n" + "	</soapProxy>\r\n" + "	\r\n" + "	<serviceProxy port=\"9000\">\r\n" + "		<basicAuthentication>\r\n" + "			<user name=\"admin\" password=\"membrane\" />\r\n" + "		</basicAuthentication>	\r\n" + "		<adminConsole />\r\n" + "	</serviceProxy>\r\n" + "	\r\n" + "	</router>\r\n" + "</spring:beans>", sl);
        String endpoint = "http://localhost:2000/MyBLZService";
        String result = getAndAssert200(endpoint + "?wsdl");
        assertContains("wsdl:documentation", result);
        // assert that rewriting did take place
        assertContains("localhost:2000/MyBLZService", result);
        result = AssertUtils.postAndAssert200(endpoint, "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:blz=\"http://thomas-bayer.com/blz/\">\r\n" + "   <soapenv:Header/>\r\n" + "   <soapenv:Body>\r\n" + "      <blz:getBank>\r\n" + "         <blz:blz>37050198</blz:blz>\r\n" + "      </blz:getBank>\r\n" + "   </soapenv:Body>\r\n" + "</soapenv:Envelope>");
        assertContains("Sparkasse", result);
        AssertUtils.setupHTTPAuthentication("localhost", 9000, "admin", "membrane");
        result = getAndAssert200("http://localhost:9000/admin/");
        result.contains("BLZService");
        String invalidRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:blz=\"http://thomas-bayer.com/blz/\">\r\n" + "   <soapenv:Header/>\r\n" + "   <soapenv:Body>\r\n" + "      <blz:getBank>\r\n" + "         <blz:blz>37050198</blz:blz>\r\n" + "         <foo />\r\n" + "      </blz:getBank>\r\n" + "   </soapenv:Body>\r\n" + "</soapenv:Envelope>";
        result = postAndAssert(500, endpoint, invalidRequest);
        assertContains(".java:", result);
        AssertUtils.closeConnections();
        AssertUtils.setupHTTPAuthentication("localhost", 9000, "admin", "membrane");
        pxu.updateWith("<spring:beans xmlns=\"http://membrane-soa.org/proxies/1/\"\r\n" + "	xmlns:spring=\"http://www.springframework.org/schema/beans\"\r\n" + "	xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + "	xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd\r\n" + "					    http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd\">\r\n" + "\r\n" + "	<router>\r\n" + "	\r\n" + "	<soapProxy port=\"2000\" wsdl=\"http://www.thomas-bayer.com/axis2/services/BLZService?wsdl\">\r\n" + "		<path>/MyBLZService</path>\r\n" + "		<soapStackTraceFilter/>\r\n" + "	</soapProxy>\r\n" + "	\r\n" + "	<serviceProxy port=\"9000\">\r\n" + "		<basicAuthentication>\r\n" + "			<user name=\"admin\" password=\"membrane\" />\r\n" + "		</basicAuthentication>	\r\n" + "		<adminConsole />\r\n" + "	</serviceProxy>\r\n" + "	\r\n" + "	</router>\r\n" + "</spring:beans>", sl);
        result = postAndAssert(500, endpoint, invalidRequest);
        assertContainsNot(".java:", result);
        AssertUtils.closeConnections();
        AssertUtils.setupHTTPAuthentication("localhost", 9000, "admin", "membrane");
        pxu.updateWith("<spring:beans xmlns=\"http://membrane-soa.org/proxies/1/\"\r\n" + "	xmlns:spring=\"http://www.springframework.org/schema/beans\"\r\n" + "	xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + "	xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd\r\n" + "					    http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd\">\r\n" + "\r\n" + "	<router>\r\n" + "	\r\n" + "	<soapProxy port=\"2000\" wsdl=\"http://www.thomas-bayer.com/axis2/services/BLZService?wsdl\">\r\n" + "		<path>/MyBLZService</path>\r\n" + "		<soapStackTraceFilter/>\r\n" + "		<validator/>\r\n" + "	</soapProxy>\r\n" + "	\r\n" + "	<serviceProxy port=\"9000\">\r\n" + "		<basicAuthentication>\r\n" + "			<user name=\"admin\" password=\"membrane\" />\r\n" + "		</basicAuthentication>	\r\n" + "		<adminConsole />\r\n" + "	</serviceProxy>\r\n" + "	\r\n" + "	</router>\r\n" + "</spring:beans>", sl);
        result = postAndAssert(400, endpoint, invalidRequest);
        assertContains("Validation failed", result);
        result = getAndAssert200("http://localhost:9000/admin/service-proxy/show?name=BLZService%3A2000");
        result.contains("1 of 1 messages have been invalid");
        result = getAndAssert200(endpoint);
        assertContains("Target Namespace", result);
        result = getAndAssert200(endpoint + "/operation/BLZServiceSOAP11Binding/BLZServicePortType/getBank");
        assertContains("blz&gt;?XXX?", result);
        AssertUtils.closeConnections();
        pxu.updateWith("<spring:beans xmlns=\"http://membrane-soa.org/proxies/1/\"\r\n" + "	xmlns:spring=\"http://www.springframework.org/schema/beans\"\r\n" + "	xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + "	xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd\r\n" + "					    http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd\">\r\n" + "\r\n" + "	<router>\r\n" + "	\r\n" + "	<soapProxy port=\"2000\" wsdl=\"http://www.thomas-bayer.com/axis2/services/BLZService?wsdl\">\r\n" + "		<path>/MyBLZService</path>\r\n" + "		<soapStackTraceFilter/>\r\n" + "		<validator/>\r\n" + "	</soapProxy>\r\n" + "	\r\n" + "	<serviceProxy port=\"9000\">\r\n" + "		<basicAuthentication>\r\n" + "			<user name=\"admin\" password=\"membrane\" />\r\n" + "		</basicAuthentication>	\r\n" + "		<adminConsole />\r\n" + "	</serviceProxy>\r\n" + "	\r\n" + "	<serviceProxy port=\"2000\">\r\n" + "		<index />\r\n" + "	</serviceProxy>\r\n" + "	\r\n" + "	</router>\r\n" + "</spring:beans>", sl);
        result = getAndAssert200("http://localhost:2000");
        assertContains("/MyBLZService", result);
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) ProxiesXmlUtil(com.predic8.membrane.examples.ProxiesXmlUtil) File(java.io.File) Test(org.junit.Test)

Example 3 with Schemas

use of com.predic8.membrane.annot.generator.Schemas in project service-proxy by membrane.

the class SpringConfigurationXSDGeneratingAnnotationProcessor method process.

public void process(Model m) throws IOException {
    new Schemas(processingEnv).writeXSD(m);
    new Parsers(processingEnv).writeParsers(m);
    new Parsers(processingEnv).writeParserDefinitior(m);
    new HelpReference(processingEnv).writeHelp(m);
    new NamespaceInfo(processingEnv).writeInfo(m);
    if (processingEnv.getElementUtils().getTypeElement("org.apache.aries.blueprint.ParserContext") != null) {
        new BlueprintParsers(processingEnv).writeParserDefinitior(m);
        new BlueprintParsers(processingEnv).writeParsers(m);
    }
}
Also used : Parsers(com.predic8.membrane.annot.generator.Parsers) BlueprintParsers(com.predic8.membrane.annot.generator.BlueprintParsers) HelpReference(com.predic8.membrane.annot.generator.HelpReference) Schemas(com.predic8.membrane.annot.generator.Schemas) NamespaceInfo(com.predic8.membrane.annot.generator.NamespaceInfo) BlueprintParsers(com.predic8.membrane.annot.generator.BlueprintParsers)

Example 4 with Schemas

use of com.predic8.membrane.annot.generator.Schemas in project service-proxy by membrane.

the class QuickstartRESTTest method doit.

@Test
public void doit() throws IOException, InterruptedException {
    File baseDir = getExampleDir("quickstart-rest");
    Process2 sl = new Process2.Builder().in(baseDir).script("service-proxy").waitForMembrane().start();
    try {
        String result = getAndAssert200("http://localhost:2000/restnames/name.groovy?name=Pia");
        assertContains("Italy", result);
        AssertUtils.closeConnections();
        new ProxiesXmlUtil(new File(baseDir, "proxies.xml")).updateWith("<spring:beans xmlns=\"http://membrane-soa.org/proxies/1/\"\r\n" + "	xmlns:spring=\"http://www.springframework.org/schema/beans\"\r\n" + "	xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n" + "	xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd\r\n" + "					    http://membrane-soa.org/proxies/1/ http://membrane-soa.org/schemas/proxies-1.xsd\">\r\n" + "\r\n" + "	<router>\r\n" + "\r\n" + "       <serviceProxy name=\"names\" port=\"2000\">\r\n" + "         <path isRegExp=\"true\">/(rest)?names.*</path>\r\n" + "         <rewriter>\r\n" + "           <map from=\"/names/(.*)\" to=\"/restnames/name\\.groovy\\?name=$1\" />\r\n" + "         </rewriter>\r\n" + "         <statisticsCSV file=\"log.csv\" />\r\n" + "         <response>\r\n" + "           <regExReplacer regex=\"\\s*,\\s*&lt;\" replace=\"&lt;\" />\r\n" + "           <transform xslt=\"restnames.xsl\" />\r\n" + "         </response>\r\n" + "         <target host=\"thomas-bayer.com\" port=\"80\" />\r\n" + "       </serviceProxy>\r\n" + "     \r\n" + "       <serviceProxy name=\"Console\" port=\"9000\">\r\n" + "         <basicAuthentication>\r\n" + "           <user name=\"alice\" password=\"membrane\" />\r\n" + "         </basicAuthentication>			\r\n" + "         <adminConsole />\r\n" + "       </serviceProxy>	\r\n" + "     </router>\r\n" + "</spring:beans>", sl);
        result = getAndAssert200("http://localhost:2000/names/Pia");
        assertContains("Italy, Spain", result);
        assertContainsNot(",<", result);
        String csvLog = FileUtils.readFileToString(new File(baseDir, "log.csv"));
        assertContains("Pia", csvLog);
        AssertUtils.setupHTTPAuthentication("localhost", 9000, "alice", "membrane");
        result = getAndAssert200("http://localhost:9000/admin/");
        assertContains("ServiceProxies", result);
    } finally {
        sl.killScript();
    }
}
Also used : Process2(com.predic8.membrane.examples.Process2) ProxiesXmlUtil(com.predic8.membrane.examples.ProxiesXmlUtil) File(java.io.File) Test(org.junit.Test)

Aggregations

Process2 (com.predic8.membrane.examples.Process2)2 ProxiesXmlUtil (com.predic8.membrane.examples.ProxiesXmlUtil)2 File (java.io.File)2 Test (org.junit.Test)2 BlueprintParsers (com.predic8.membrane.annot.generator.BlueprintParsers)1 HelpReference (com.predic8.membrane.annot.generator.HelpReference)1 NamespaceInfo (com.predic8.membrane.annot.generator.NamespaceInfo)1 Parsers (com.predic8.membrane.annot.generator.Parsers)1 Schemas (com.predic8.membrane.annot.generator.Schemas)1 Schema (com.predic8.schema.Schema)1 Types (com.predic8.wsdl.Types)1 WSDLParser (com.predic8.wsdl.WSDLParser)1 WSDLParserContext (com.predic8.wsdl.WSDLParserContext)1 ArrayList (java.util.ArrayList)1