有没有办法使用生产者模板设置camel exchange属性?
想象一下,接收客户订单的休息端点(尚未在骆驼路线中).使用生产者模板,我想
是的,我也可以使用头文件并在使用生产者模板时使用producerTemplate.sendBodyWithHeaders,但我正在考虑使用属性而不是头文件,因为这就是属性的意思 - 路径与头部内的元数据是更多元数据到与外部世界沟通.Customer-Id对我来说没有任何意义.
我有一个休息端点sample.org,它返回表单的json响应
{
"response" : "pending"
}
Run Code Online (Sandbox Code Playgroud)
我的路线看起来像这样
from("http://sample.org")
.marshal(xmlFormatConverterUtil.getxmlJsonDataFormat()) //To convert into json as I receive data in xml format which needs to be converted to json
Run Code Online (Sandbox Code Playgroud)
我读到了关于轮询消费者但没有找到关于如何继续轮询端点的示例,直到它将响应返回为"成功".
是否应该使用民意调查消费者?如果是这样,可以举例说明与我的案例相关的例子.轮询其余端点的任何其他资源都非常有用.
我正在尝试使用骆驼制作一个程序。该程序应该能够在名为inbox_xml_files的文件夹中接收 xml 文件。
然后程序应该获取xml 文件内<Country>元素节点的文本值。
如果文本值为“Denmark”,则文件应移动到名为“outbox_Denmark”的文件夹。
如果文本值为“Sweden”,则文件应移动到名为“outbox_Sweden”的文件夹。
如果文本值是其他内容,则应将文件移动到名为“outbox_Other”的文件夹。
这是我用于测试的 XML 文件:
<?xml version="1.0"?>
<Company>
<Employee>
<FirstName>Mike</FirstName>
<LastName>James</LastName>
<ContactNo>1234567890</ContactNo>
<Email>oy@hotmail.com</Email>
<Address>
<Country>Denmark</Country>
<City>Copenhagen</City>
<Zip>1234</Zip>
</Address>
</Employee>
</Company>
Run Code Online (Sandbox Code Playgroud)
骆驼 xml 文件(我遇到麻烦的那个):
<camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
<camel:route id="_route1">
<camel:from id="_from1" uri="file:C:/inbox_xml_files?noop=false"/>
<camel:choice id="_choice1">
<camel:when id="_when1">
<camel:xpath>
//Company/Employee/Address/Country = 'Denmark'
</camel:xpath>
<camel:to id="_to1" uri="file:C:/outbox_Denmark"/>
</camel:when>
<camel:when id="_when2">
<camel:xpath>
//Company/Employee/Address/Country = 'Sweden'
</camel:xpath>
<camel:to id="_to2" uri="file:C:/outbox_Sweden"/>
</camel:when>
<camel:otherwise id="_otherwise1">
<camel:to id="_to3" uri="file:C:/outbox_Other"/>
</camel:otherwise>
</camel:choice>
</camel:route>
</camelContext>
Run Code Online (Sandbox Code Playgroud)
我相信问题出在<camel:xpath>内部。我认为我的定义是错误的,我正在尝试,但这一切对我来说都是新的东西,所以我正在努力解决它。
你能给我一个例子来说明如何在我的库中声明函数指针吗?如何将函数指针传递给外部库?
好的,首先通过查看此网址听我说:
http://api.flickr.com/services/feeds/photos_public.gne?format=json
注意Description字符串如何在其中包含非编码的html,例如<,>等.
以下是我使用ASP.NET 3.5和C#返回JSON的方法:
context.Response.ContentType = "text/plain";
context.Response.Charset = Encoding.UTF8.ToString();
int i = 1;
List<Product> products = GetTestProducts();
List<CrImageList> imageList = new List<CrImageList>();
foreach(Product p in products)
{
string imageTag = HttpUtility.HtmlEncode(string.Format(@"<img src=""{0}"" alt="""">", ImageUrl(p.Image, false)));
imageList.Add(new CrImageList{ImageTag = imageTag});
i++;
}
string jsonString = imageList.ToJSON();
context.Response.Write(jsonString);
Run Code Online (Sandbox Code Playgroud)
以下是此代码返回的JSON,当我点击我的.ashx时调用它,并在包含它的方法中调用此代码:
[{"ImageTag":"<img src="http://www.ourdomain.com/image/540.jpg" alt="">"},{"ImageTag":"<img src="http://www.ourdomain.com/image/642.jpg" alt="">"}]
Run Code Online (Sandbox Code Playgroud)
现在,我如何才能将编码后的字符实际显示为我的JSON返回的文本字符串中的html字符?
我希望<to show <等等,就像Flickr能够用他们的JSON一样.
如果我拿出HtmlEncode:
string.Format(@"",ImageUrl(p.Image,false));
然后我开始在我的字符串中获取/ u00:
[{"ImageTag":"\u003cimg src=\"http://www.example.com/cat_image/540.jpg\" alt=\"\"\u003e"},
...
Run Code Online (Sandbox Code Playgroud)
那么为什么Flickr的JSON在其描述中没有返回任何干净的HTML?
我在过去的一年里一直在研究PHP,现在我正在学习Rails.
在rails中: - 路由获取传入的URL并将其解码为一组参数,Rails使用这些参数调度到适当的控制器和操作
例如
rs.recognize_path "/blog/show/123"
{:controller=>"blog", :action=>"show", :id=>"123"}
Run Code Online (Sandbox Code Playgroud)
我对吗?
我们在config目录下的routes.rb中提到了这个(写下来的)代码行,告诉rails如何使用这行代码来处理像"/ blog/show/123"这样的请求.
map.connect "blog/show/:id", :controller => "blog", :action => "show", :id => /\d+/
Run Code Online (Sandbox Code Playgroud)
现在在PHP中我们做这样的事情
www.example.com/profile.php?profile_id=2
Run Code Online (Sandbox Code Playgroud)
请求如何发送到请求的页面?意味着我从未在PHP中编写任何用于路由的内容,那么hss如何处理这个请求呢?如何在PHP中完成路由(在学习/使用PHP时我错过了什么)?
希望你能得到我所要求的.如果有任何部分不清楚,请告诉我.
我有一个WCF服务合同,定义如下:
[OperationContract]
[WebGet(
UriTemplate =
"HubContent/{language}?apptype={appType}"
,
ResponseFormat = WebMessageFormat.Json)]
HubResults GetHubContent(string language, string appType);
Run Code Online (Sandbox Code Playgroud)
在服务中实现此契约时,我返回一个在JSON中解析出来的对象列表.但是,只要对象的某个属性是URL或包含正斜杠的任何字符串,服务器在浏览器中返回的JSON就会转义正斜杠.所以这个网址: - http://www.example.com/test/site将会是这样的
http\/\/www.example.com\/test\/site.
Run Code Online (Sandbox Code Playgroud)
是否有一些我需要在与格式相关的合同中指定以纠正此问题?
我有这个网址:
http://www.example.com/get_url.php?ID=100&Link=http://www.test.com/page.php?l=1&m=7
Run Code Online (Sandbox Code Playgroud)
当我打印时$_GET['Link'],我只看到了http://www.test.com/page.php?l=1.
在哪里&m=7?
我有这样的网址
我需要从URL获取文件的路径为/ mnt/sdcard/video.我怎么做 ?我使用URL解码器删除空格,但我对获取文件的路径感到困惑.感谢你的帮助.
array = ["abc","mohasdan","321","324324"]
recipients = ["xxx@example.com"]
recipients_formatted = []
recipients.each {|s| recipients_formatted << "To: #{s}"}
message = <<MESSAGE_END
From: xxx@example.com <xxx@example.com>
#{recipients_formatted}
MIME-Version: 1.0
Content-type: text/html
Subject: Chef Report
<html>
<head>
<style type="text/css">
table {border-collapse:collapse;}
table, td, th {border:1px solid black;padding:5px;}
</style>
</head>
<body>
<h2>Chef Check-in Report</h2>
<p>
<p>
<table border=1>
<tr>
<th>Node</th>
<th>Time Since Last Check-in (Mins)</th>
</tr>
</table>
</body>
</html>
MESSAGE_END
Net::SMTP.start('localhost') do |smtp|
smtp.send_message message, 'xxx@example.com',
recipients
end
Run Code Online (Sandbox Code Playgroud)
上面的代码发送一个包含表格的电子邮件,如下所示:
Chef (column1) | Check-in Report(column2) (row 1)
Run Code Online (Sandbox Code Playgroud)
我将数组内容放入要通过电子邮件发送的表中.我希望第一行的第一列中的第一个数组元素,第一行的第二列中的第二个数组元素.第二行第一列中的第三个数组元素,第二行第二列中的第四个数组元素,依此类推.