[rules-users] REST API new asset

nicoktay aoktaykabar at gmail.com
Wed Jan 30 12:09:10 EST 2013


Thanks for the reply Jervis,

Regarding to the problem I tried to create a RuleModel and wanted to store
this as drl asset.
Followed your suggestion but still I am mistaken in somewhere. 

 String drl = p.marshal(rulemodel);

WebClient client =
WebClient.create("http://127.0.0.1:8080/","admin","admin",null);   
InputStream source = new ByteArrayInputStream(read.marshal(m).getBytes());        
Response response=
client.path("guvnor-5.4.0.Final-jboss-as-7.0/rest/packages/mortgages/assets").accept("application/xml").post(source);


and I had following error


*30-ene-2013 18:00:10 org.apache.cxf.phase.PhaseInterceptorChain
doDefaultLogging
ADVERTENCIA: Interceptor for {http://127.0.0.1:8080/}WebClient has thrown
exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
	at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:247)
	at
org.apache.cxf.jaxrs.client.WebClient.doChainedInvocation(WebClient.java:616)
	at org.apache.cxf.jaxrs.client.WebClient.doInvoke(WebClient.java:596)
	at org.apache.cxf.jaxrs.client.WebClient.invoke(WebClient.java:241)
	at org.apache.cxf.jaxrs.client.WebClient.post(WebClient.java:250)
	at ExpertSystem.Main_FireRules.testRuleModel(Main_FireRules.java:281)
	at ExpertSystem.Main_FireRules.main(Main_FireRules.java:68)
Caused by: java.io.IOException: Server returned HTTP response code: 415 for
URL:
http://127.0.0.1:8080/guvnor-5.4.0.Final-jboss-as-7.0/rest/packages/mortgages/assets
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown
Source)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2190)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2071)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1925)
	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:662)
	at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
	... 7 more
Caused by: java.io.IOException: Server returned HTTP response code: 415 for
URL:
http://127.0.0.1:8080/guvnor-5.4.0.Final-jboss-as-7.0/rest/packages/mortgages/assets
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)
	at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2102)
	... 12 more*


Will be greatful for any help thanks,

Nicoktay.



Jervis Liu wrote
> On 2013/1/30 0:10, nicoktay wrote:
>> Hi all,
>>
>> I was trying to use POST method of REST API to create new asset and
>> insert
>> it into guvnor as in the document
>> http://docs.jboss.org/drools/release/5.5.0.Final/drools-guvnor-docs/html/ch09.html#d0e3500
>> <http://docs.jboss.org/drools/release/5.5.0.Final/drools-guvnor-docs/html/ch09.html#d0e3500>
>>
>> Below I tried to create new asset using POST, please guide me where I was
>> wrong.
>>
>> WebClient client =
>> WebClient.create("http://127.0.0.1:8080/","admin","admin",null);
>>         
>> Response response=
>> client.path("guvnor-5.4.0.Final-jboss-as-7.0/rest/packages/mortgages/assets/newtechnicalrule.drl").accept("text/plain").post(rule);
>> // rule is string drl which will be created with the name of
>> "newtechnicalrule.drl".
> When you use POST to create an asset, the correct url is 
> http://localhost:8080/guvnor-5.5.0.Final/rest/packages{packageName}/assets 
> <http://localhost:8080/guvnor-5.5.0.Final/rest/packages%7BpackageName%7D/assets>
> 
> The POST method produces MIME-Types of application/atom+xm, not
> "text/plain"
> 
> Cheers,
> Jervis
> 
>   *
> 
> 
> 
>>
>> Welcome to any help thanks,
>>
>> Nicoktay.
>>
>>
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/REST-API-new-asset-tp4021927.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> 

> rules-users at .jboss

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

> rules-users at .jboss

> https://lists.jboss.org/mailman/listinfo/rules-users





--
View this message in context: http://drools.46999.n3.nabble.com/REST-API-new-asset-tp4021927p4021969.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list