Guvnor drools 5.5 rest api 用于创建模型和规则资产
Guvnor drools 5.5 rest api for creating model and rule asset
我正在尝试通过休息在 guvnor 中创建资产 api。但是资产正在 guvnor.How 中的其他资产下创建为 txt,我可以将其设为规则资产或模型资产吗?下面是我的代码
Client client = ClientBuilder.newClient();
client.register(HttpAuthenticationFeature.basic("admin", "admin"));
client.register(MultiPartFeature.class);
final MultiPart multipart = new FormDataMultiPart();
File file = new File("C:\assetfile.xml");
multipart.bodyPart(new FormDataBodyPart("asset",file,MediaType.APPLICATION_XML_TYPE));
final Response response = client.target("http://localhost:8080/guvnor-5.5.0.Final-tomcat-6.0/rest/packages/samplePackage/assets")
.request()
.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
System.out.println(response.readEntity(String.class));
client.close();
我的 xml 文件是
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<asset>
<author>admin</author>
<description/>
<metadata>
<checkInComment/>
<disabled>false</disabled>
<format>brl<format>
<versionNumber>1</versionNumber>
</metadata>
<sourceLink>
http://localhost:8080/guvnor-5.5.0.Final-tomcat-6.0/rest/packages/samplePackage/assets/location1234/source
</sourceLink>
<title>location1234</title>
</asset>
根据 https://simplesassim.wordpress.com/tag/drools-guvnor-rest-api/,您可能还需要将文件内容添加为 "binary" 参数。
multipart.bodyPart(new FormDataBodyPart("asset",file,MediaType.APPLICATION_XML_TYPE));
multipart.bodyPart(new FormDataBodyPart("binary",file)); // Add this line
希望以上修改对您有所帮助。
我正在尝试通过休息在 guvnor 中创建资产 api。但是资产正在 guvnor.How 中的其他资产下创建为 txt,我可以将其设为规则资产或模型资产吗?下面是我的代码
Client client = ClientBuilder.newClient();
client.register(HttpAuthenticationFeature.basic("admin", "admin"));
client.register(MultiPartFeature.class);
final MultiPart multipart = new FormDataMultiPart();
File file = new File("C:\assetfile.xml");
multipart.bodyPart(new FormDataBodyPart("asset",file,MediaType.APPLICATION_XML_TYPE));
final Response response = client.target("http://localhost:8080/guvnor-5.5.0.Final-tomcat-6.0/rest/packages/samplePackage/assets")
.request()
.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
System.out.println(response.readEntity(String.class));
client.close();
我的 xml 文件是
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<asset>
<author>admin</author>
<description/>
<metadata>
<checkInComment/>
<disabled>false</disabled>
<format>brl<format>
<versionNumber>1</versionNumber>
</metadata>
<sourceLink>
http://localhost:8080/guvnor-5.5.0.Final-tomcat-6.0/rest/packages/samplePackage/assets/location1234/source
</sourceLink>
<title>location1234</title>
</asset>
根据 https://simplesassim.wordpress.com/tag/drools-guvnor-rest-api/,您可能还需要将文件内容添加为 "binary" 参数。
multipart.bodyPart(new FormDataBodyPart("asset",file,MediaType.APPLICATION_XML_TYPE));
multipart.bodyPart(new FormDataBodyPart("binary",file)); // Add this line
希望以上修改对您有所帮助。