I have created REST service using JBossFuse JAX-RS, the XML file is as below.
Can anyone help me to enable SSL/TLS to this service?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<jaxrs:server address="http://localhost:9000/employee" id="EmplRestService">
<jaxrs:serviceBeans>
<ref bean="EmplService"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="EmplService" class="com.sample.beans.EmployeeServiceResource"/>
</beans>
Thanks
Since you are using the absolute address
address="http://localhost:9000/employee"
You need configure httpj:engine-factory as described here[1]
[1]http://cxf.apache.org/docs/standalone-http-transport.html
Related
I am trying to create an HTTPS connector in Mule so that I can call an HTTPS endpoint as part of a flow. However when I try to add the sslType spring property, I get an error.
I have an HTTPS connector defined as so:
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:core="http://www.mulesoft.org/schema/mule/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:https="http://www.mulesoft.org/schema/mule/https"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.5.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper"
xmlns:domain="http://www.mulesoft.org/schema/mule/ee/domain"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/domain http://www.mulesoft.org/schema/mule/ee/domain/current/mule-domain-ee.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd">
...
<https:connector name="HTTPSConnector" doc:name="HTTPS-Connector"
cookieSpec="netscape" validateConnections="true" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0"
clientSoTimeout="${service.timeout}" serverSoTimeout="60000" socketSoLinger="0">
<spring:property name="sslType" value="TLSv1.2" />
</https:connector>
...
Mule is throwing the error:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'spring:property'.
One of '{"http://www.mulesoft.org/schema/mule/core":service-overrides, "http://www.mulesoft.org/schema/mule/https":tls-client, "http://www.mulesoft.org/schema/mule/https":tls-key-store, "http://www.mulesoft.org/schema/mule/https":tls-server, "http://www.mulesoft.org/schema/mule/https":tls-protocol-handler}' is expected.
What changes do I need to get this property recognised?
It works without issues for me running in 3.5.2, if that is the version you are using. Maybe there is something else in the omitted snippets? If there other configurations inside the <https:connector> element that are not shown in the snippet shared then ensure that `spring:property is the first one.
Note that even if it works you might be finding some other issues related to the SSL engine and Java SSL support to make it work with TLS 1.2. For example 3.5.2 only supports Java 7. You might find some bug, mentioned at https://help.mulesoft.com/s/article/Setting-the-TLS-version-for-the-legacy-HTTPS-connector. Both Mule 3.5 and Java 7 are at end of life.
If you are using a current Mule 3 version, Mule 3.9.5 is recommended as the latest and greatest at this time, then TLS 1.2 support is the default. Same with Mule 4.x. Having said that, the legacy HTTP connector you are using has been deprecated for several years, and the new HTTP Listener/HTTP Requester that replace it are recommended.
I have a requirement that to configure the database connector using my custom-defined Datasource(Spring based). When configuring my data-source to DB Connector with my custom bean, I am getting an error that cannot set javax.sql.Datasource to org.mule.extension.db.internal.domain.data source.DataSourceConnetionSettings.dataSourceRef. When I didn't configure my DB connector and referred to the data source using java invoke, able to get the Datasource object. How can I pass this Datasource this my database connector in runtime?
Referred to the below but didn't help.
https://help.mulesoft.com/s/article/Spring-based-datasources
Can someone help me with the last point in the below knowledgebase?
https://help.mulesoft.com/s/article/How-to-configure-connector-with-dynamic-parameters
<db:config name="Database_Config">
<db:data-source-connection dataSourceRef="myDbConnetor" />
</db:config>
My beans.xml as like below:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:annotation-config />
<context:component-scan base-package="com.test.datasource.*" />
<bean id="myDbConnetor" class="com.test.datasource.MyCustomDataSource"/>
</beans>
I am very very new to Apache Camel and I am looking to create a simple application which reads 200 products from mysql db 1 and then inserts the products into mysql db 2. No changes required to the data, it is just a one for one bulk select and then bulk insert.
I have been looking at the camel-sql-example project which uses the sql component. I like the way it's structured so I've attempted to go with this example project as my base.
Would anyone be able to help me with the location of a good example for this or giving me a rough indication of what my camel route (spring arcehtype) should look like?
Is something like this correct?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="sourceDataSource" class="org.apache.commons.dbcp.BasicDataSource">
...
</bean>
<bean id="targetDataSource" class="org.apache.commons.dbcp.BasicDataSource">
...
</bean>
<!-- configure the Camel SQL component to use the JDBC data source -->
<bean id="sourceSql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="sourceDataSource"/>
</bean>
<bean id="targetSql" class="org.apache.camel.component.sql.SqlComponent">
<property name="dataSource" ref="targetDataSource"/>
</bean>
<bean id="productBean" class="org.apache.camel.example.sql.ProductBean"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<propertyPlaceholder location="classpath:sql.properties" id="placeholder"/>
<route id="processProduct-route">
<from uri="sourceSql:{{sql.selectProduct}}"/>
<to uri="targetSql:{{sql.insertProduct}}"/>
<log message="${body}"/>
</route>
</camelContext>
thanks
I tested this today and what I've specified above seems to work! Something that I did not expect though was that the route just loops and continues to run multiple times. I only need it to run once. I'm looking into how to achieve this.
I have written a simple authentication/authorization plugin that I want to inject into ActiveMQ. I want it to be called onConnect and onSubscribe. I have followed these steps at the ActiveMQ website but a couple of things happen.
1) If I put in my bean declaration in the default activemq.xml file in //beans/broker/plugins I get a validation error saying that the node "bean" is not allowed there.
2) If I put the plugin declaration outside of the broker element it will inject the element, but it will not call installPlugin() nor the hooks, presumably because that is for the broker to do.
3) If I change the XML namespace declaration in the default activemq.xml (http://activemq.apache.org/schema/core) to that which is stated in the docs listed above (http://activemq.org/config/1.0) along with the proper URLs, I get the error that it cannot find the schema document.
The only thing I can come up with is that either there were changes in 5.6 that were not reflected in the documentation, I'm doing something very wrong, or I'm just crazy. Here is the relevant portion of the xml doc (minus several nodes not directly related to the problem).
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.org/config/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
<plugins>
<bean id="tokenLoginPlugin" class="auth.TokenLoginPlugin">
<property name="host" value="localhost" />
</bean>
</plugins>
</broker>
This generates the following exception.
The matching wildcard is strict, but no declaration can be found for element 'broker'.
If I use the xmlns declarations from the default activemq.xml file, I get the following.
Invalid content was found starting with element 'bean'
I can see that it's a validation error, but none of the docs seem to be pointing me in the right direction.
Figured it out, though I had tried it before and it hadn't worked. Perhaps I had messed up my namespaces the last time. I changed my plugin definition and added the Spring namespace to my bean declaration.
<plugins>
<bean id="tokenLoginPlugin" class="auth.TokenLoginPlugin" xmlns="http://www.springframework.org/schema/beans">
<property name="host" value="localhost" />
</bean>
</plugins>
My configuration is :
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<plugins>
<bean xmlns="http://www.springframework.org/schema/beans" id="probePlugin" class="com.ProbePlugin"/>
</plugins>
</beans>
I've built a simple Spring WS (1.5.9) and I'm trying to deploy it to Glassfish v3. Unfortunately the deployment fails for the above reason. I've struggled to resolve the issue myself but it clearly not able to resolve the "bean" element.
Heres me spring-ws-servlet.xml (bean definitions):
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...bean definitions
</beans>
I've also tried it with the schemaLocation set to spring-beans-3.0.xsd with the same result.
My WAR only has one dependency and that is Spring-WS.
You haven't provided the standard collection of schema locations, particularly not the required schema location for the beans schema.
Here's one of mine:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:gate="http://gate.ac.uk/ns/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://gate.ac.uk/ns/spring http://gate.ac.uk/ns/spring.xsd
">
</beans>
The same fail was happened to me when I copied the beans tag from another file on internet, you have to secure that you've typped a space between the html sentences.
<beans xmlns="http://www.springframework.org/schema/beans"(space)xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"(space)
xmlns:context="http://www.springframework.org/schema/context"(space)
....
">
</beans>