I installed drools-server (5.2 final) in tomcat and was able to invoke the 
sample Soap service using SoapUI using Salaboy's excellent blog post 
instructions.  I have modified knowledge-services.xml to add my rule base using 
a knowledge agent, and changed camel-server.xml to marshal/unmarshal using 
serialization.  The drools-server starts up without error, but when I try to 
call the rest service from my java client, I get  HTTP response: status code = 
415, status message = [Unsupported Media Type].

Any suggestions or example of how to do this?  I am attaching my xml files.  
the application-Context-rulesTestIntegrationExamples.xml is the spring bean 
definition for my client java program.


<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : applicationContext-rulesTests.xml
    Created on : 24 May 2011
    Author     : lhorton
    Description:
        Spring Framework Application Context for RulesTestIntegration.java
-->

<beans xmlns="http://www.springframework.org/schema/beans";
    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-3.0.xsd";>

	<bean id="droolsServer" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
		<property name="serviceUrl" value="http://192.168.57.128:8280/drools-server/kservice/rest/execute"/>
		<property name="serviceInterface" value="org.drools.command.CommandService"/>
		<property name="httpInvokerRequestExecutor">
			<bean class="org.springframework.remoting.httpinvoker.CommonsHttpInvokerRequestExecutor">
				<property name="readTimeout" value="20000"/>
				<property name="httpClient">
					<bean class="org.apache.commons.httpclient.HttpClient">
						<property name="timeout" value="20000"/>
                        <property name="httpConnectionManager">
                            <bean class="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager"/>
                        </property>
					</bean>
				</property>
			</bean>
		</property>
	</bean>

</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You 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.
-->
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:cxf="http://camel.apache.org/schema/cxf";
       xmlns:jaxrs="http://cxf.apache.org/jaxrs";
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.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
    ">
    
  <import resource="classpath:META-INF/cxf/cxf.xml" />
  <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
  <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

  <!--
      !   If you are running on JBoss you will need to copy a camel-jboss.jar into the lib and set this classloader configuration 
      |  http://camel.apache.org/camel-jboss.html
      <bean id="jbossResolver" class="org.apache.camel.jboss.JBossPackageScanClassResolver"/>
      -->

  <!--
   !   Define the server end point.
   !   Copy and paste this element, changing id and the address, to expose services on different urls.
   !   Different Camel routes can handle different end point paths.
    --> 
  <cxf:rsServer id="rsServer"  
                address="/rest"
                serviceClass="org.drools.jax.rs.CommandExecutorImpl">
       <cxf:providers>
           <bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
       </cxf:providers>
  </cxf:rsServer>  
  
  <cxf:cxfEndpoint id="soapServer"
            address="/soap"
             serviceName="ns:CommandExecutor"
             endpointName="ns:CommandExecutorPort"
          wsdlURL="soap.wsdl"
          xmlns:ns="http://soap.jax.drools.org/"; >
    <cxf:properties>
      <entry key="dataFormat" value="MESSAGE"/>
      <entry key="defaultOperationName" value="execute"/>
    </cxf:properties>
  </cxf:cxfEndpoint>

  <!-- Leave this, as it's needed to make Camel "drools" aware -->
  <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />  
    
  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring";>    
    <!-- 
     ! Routes incoming messages from end point id="rsServer".
     ! Example route unmarshals the messages with xstream and executes against ksession1.
     ! Copy and paste this element, changing marshallers and the 'to' uri, to target different sessions, as needed.
     !-->
     
    <route>
       <from uri="cxfrs://bean://rsServer"/>
       <policy ref="droolsPolicy">
        <unmarshal><serialization/> </unmarshal>
         <to uri="drools:droolsClusterNode1/workflowKnowledgeSession" />
        <marshal><serialization/></marshal>
       </policy>
    </route>    

    <route>
      <from uri="cxf://bean://soapServer"/>
      <policy ref="droolsPolicy">
        <unmarshal ref="xstream" />       
        <to uri="drools:node1/ksession1" />
        <marshal ref="xstream" />
      </policy>
    </route>
        
  </camelContext>

</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You 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.
-->
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:drools="http://drools.org/schema/drools-spring";
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring-1.3.0.xsd";>

	<drools:resource-change-scanner id="droolsChangeScanner" interval="10"/>

	<drools:grid-node id="droolsClusterNode1"/>

	<drools:kbase id="workflowKnowledgeBase" node="droolsClusterNode1"/>

	<drools:kagent id="workflowKnowledgeAgent" kbase="workflowKnowledgeBase" new-instance="true">
		<drools:resources>
			<drools:resource type="CHANGE_SET" source="file:///usr/local/tomcat-rules/webapps/drools-server/WEB-INF/classes/WorkflowChangeSet.xml"/>
		</drools:resources>
	</drools:kagent>

	<drools:ksession id="workflowKnowledgeSession" type="stateless" kbase="workflowKnowledgeBase" node="droolsClusterNode1"/>

	<drools:grid-node id="node1"/>

	<drools:kbase id="kbase1" node="node1">
		<drools:resources>
			<drools:resource  type="DRL" source="classpath:test.drl"/>
		</drools:resources>
	</drools:kbase>

	<drools:ksession id="ksession1" type="stateless" kbase="kbase1" node="node1"/>

</beans>
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to