在本文中,您将会了解到关于Android:如何在网站包含时下载RSS:linkrel=“alternate”type=“application/rssxml”的新资讯,并给出一些关于$.ajax中co
在本文中,您将会了解到关于Android:如何在网站包含时下载RSS:link rel =“alternate”type =“application / rss xml”的新资讯,并给出一些关于$.ajax中contentType: “application/json” 的用法、$.ajax中contentType: “application/json” 的用法详解、.net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”、2 pieces of AFE papers——initiation,Alternative Promoters(both for the first exon splice)的实用技巧。
本文目录一览:- Android:如何在网站包含时下载RSS:link rel =“alternate”type =“application / rss xml”
- $.ajax中contentType: “application/json” 的用法
- $.ajax中contentType: “application/json” 的用法详解
- .net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”
- 2 pieces of AFE papers——initiation,Alternative Promoters(both for the first exon splice)
Android:如何在网站包含时下载RSS:link rel =“alternate”type =“application / rss xml”
我希望能够下载仅包含以下网站URL的RSS(xml):
link rel =“alternate”type =“application / RSS xml”
例如,http://www.engaget.com源包含:
<link rel="alternate" type="application/RSS+xml" title="Engadget" href="http://www.engadget.com/RSS.xml">
我假设如果我将此站点作为RSS应用程序打开,它将重定向到http://www.engadget.com/rss.xml页面.
我下载xml的代码如下:
private boolean downloadXml(String url,String filename) { try { URL urlxml = new URL(url); URLConnection ucon = urlxml.openConnection(); ucon.setConnectTimeout(4000); ucon.setReadTimeout(4000); InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is,128); FileOutputStream fOut = openFileOutput(filename + ".xml",Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE); OutputStreamWriter osw = new OutputStreamWriter(fOut); int current = 0; while ((current = bis.read()) != -1) { osw.write((byte) current); } osw.flush(); osw.close(); } catch (Exception e) { return false; } return true; }
在我不知道’http://www.engadget.com/RSS.xml’url的情况下,当我输入’http://www.engadget.com’时如何下载RSS?
解决方法
>检测URL是否指向HTML文件.请参阅下面的代码中的isHtml方法.
>如果URL指向HTML文件,请从中提取RSS URL.请参阅下面的代码中的extractRSSUrl方法.
以下代码是您在问题中粘贴的代码的修改版本.对于I / O,我使用Apache Commons IO作为有用的IoUtils和FileUtils类. IoUtils.toString用于将输入流转换为字符串,如文章“In Java,how do I read/convert an InputStream to a String?”中所建议的那样
extractRSSUrl使用正则表达式来解析HTML,即使它非常不受欢迎. (参见“RegEx match open tags except XHTML self-contained tags”中的咆哮.)考虑到这一点,让extractRSSUrl成为一个起点. extractRSSUrl中的正则表达式是基本的,并未涵盖所有情况.
请注意,对isRSS(str)的调用已被注释掉.如果要进行RSS检测,请参阅“How to detect if a page is an RSS or ATOM feed”.
private boolean downloadXml(String url,String filename) { InputStream is = null; try { URL urlxml = new URL(url); URLConnection ucon = urlxml.openConnection(); ucon.setConnectTimeout(4000); ucon.setReadTimeout(4000); is = ucon.getInputStream(); String str = IoUtils.toString(is,"UTF-8"); if (isHtml(str)) { String RSSURL = extractRSSUrl(str); if (RSSURL != null && !url.equals(RSSURL)) { return downloadXml(RSSURL,filename + ".xml"); } } else { // if (isRSS(str)) { // For Now,we''ll assume that we''re an RSS Feed at this point FileUtils.write(new File(filename),str); return true; } } catch (Exception e) { // do nothing } finally { IoUtils.closeQuietly(is); } return false; } private boolean isHtml(String str) { Pattern pattern = Pattern.compile("<html",Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE); Matcher matcher = pattern.matcher(str); return matcher.find(); } private String extractRSSUrl(String str) { Pattern pattern = Pattern.compile("<link(?:\\s+href=\"([^\"]*)\"|\\s+[a-z\\-]+=\"[^\"]*\")*\\s+type=\"application/RSS\\+(?:xml|atom)\"(?:\\s+href=\"([^\"]*)\"|\\s+[a-z\\-]+=\"[^\"]*\")*?\\s*/?>",Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE); Matcher matcher = pattern.matcher(str); if (matcher.find()) { for (int i = 1; i <= matcher.groupCount(); i++) { if (matcher.group(i) != null) { return matcher.group(i); } } } return null; }
上面的代码适用于您的Engadget示例:
obj.downloadXml("http://www.engadget.com/","RSS");
$.ajax中contentType: “application/json” 的用法
https://blog.csdn.net/calyxmelo/article/details/54969244
不使用contentType: “application/json”则data可以是对象 $.ajax({ url: actionurl,type: "POST",datType: "JSON",data: { id: nodeId },async: false,success: function () {} }); 1 2 3 4 5 6 7 8 使用contentType: “application/json”则data只能是json字符串 $.ajax({ url: actionurl,contentType: "application/json" data: "{‘id‘: " + nodeId +"}",success: function () {} });
//请求后端接口,获取数据function getRequestData(method,url,reqData,callBack){ $.ajax({ type : method,url : url,data : JSON.stringify(reqData),contentType:"application/json",dataType:‘json‘,success : function(result) { callBack(result); } });}
$.ajax中contentType: “application/json” 的用法详解
具体内容如下所示:
$.ajax({ type: httpMethod, cache:false, async:false, contentType: "application/json; charset=utf-8", dataType: "json",//返回值类型 url: path+url, data:jsonData, success: function(data){ var resultData = ''返回码=''+data.status+'',响应结果=''+data.message+'',耗时=''+data.tcost; layer.msg(resultData,{icon: 1}); }, error : function(xhr, ts, et) { layer.msg(''服务调用失败!'', {icon: 2}); } });
区分:
contentType: 发送信息至服务器时内容编码类型,简单说告诉服务器请求类型的数据
默认值: "application/x-www-form-urlencoded"
dataType:告诉服务器,我要想什么类型的数据,除了常见的json、XML,还可以指定 html、jsonp、script或者text
不使用contentType: “application/json”则data可以是对象
$.ajax({ url: actionurl, type: "POST", datType: "JSON", data: { id: nodeId }, async: false, success: function () {} });
使用contentType: “application/json”则data只能是json字符串
$.ajax({ url: actionurl, type: "POST", datType: "JSON", contentType: "application/json" data: "{''id'': " + nodeId +"}", async: false, success: function () {} });
总结
以上所述是小编给大家介绍的$.ajax中contentType: “application/json” 的用法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
- 跨域解决之JSONP和CORS的详细介绍
- JSON生成Form表单的方法示例
- 简单说说angular.json文件的使用
- JavaScript根据json生成html表格的示例代码
- MongoDB使用mongoexport和mongoimport命令,批量导出和导入JSON数据到同一张表的实例
- nodejs读取本地中文json文件出现乱码解决方法
- Go语言的JSON处理详解
- JavaScript JSON使用原理及注意事项
.net – 消耗webservice的错误,内容类型“application/xop xml”与预期类型不匹配“text/xml”
每当我尝试调用webservice上的任何方法时,调用实际上会成功,但是当处理响应时客户端失败,并且我收到异常。
错误的细节如下,谢谢你们可以提供的任何帮助。
使用Web引用错误(旧式webservice客户端)
当作为Web引用使用该服务时,我得到一个InvalidOperationException用于我所做的任何调用,并显示以下消息:
Client found response content type of ''multipart/related; type="application/xop+xml"; boundary="uuid:170e63fa-183c-4b18-9364-c62ca545a6e0"; start="<root.message@cxf.apache.org>"; start-info="text/xml"'',but expected ''text/xml''. The request Failed with the error message: -- --uuid:170e63fa-183c-4b18-9364-c62ca545a6e0 Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"; Content-transfer-encoding: binary Content-ID: <root.message@cxf.apache.org> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:openApiConnectionResponse xmlns:ns2="http://api.service.apibatchmember.emailvision.com/" xmlns:ns3="http://exceptions.service.apibatchmember.emailvision.com/"> <return>DpKTe-9swUeOsxhHH9t-uLPeLyg-aa2xk3-aKe9oJ5S9Yymrnuf1FxYnzpaFojsQSkSCbJsZmrZ_d3v2-7Hj</return> </ns2:openApiConnectionResponse> </soap:Body> </soap:Envelope> --uuid:170e63fa-183c-4b18-9364-c62ca545a6e0-- --.
如你所见,响应肥皂包看起来是有效的(这是一个有效的响应,并且调用成功),但客户端似乎对内容类型有问题并产生异常。
使用服务引用错误(WCF客户端)
当我将服务作为服务参考使用时,我会收到一个ProtocolException用于我所做的任何调用,并显示以下消息:
The content type multipart/related; type="application/xop+xml"; boundary="uuid:af66440a-012e-4444-8814-895c843de5ec"; start="<root.message@cxf.apache.org>"; start-info="text/xml" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder,be sure that the IsContentTypeSupported method is implemented properly. The first 648 bytes of the response were: '' --uuid:af66440a-012e-4444-8814-895c843de5ec Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"; Content-transfer-encoding: binary Content-ID: <root.message@cxf.apache.org> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ns2:openApiConnectionResponse xmlns:ns2="http://api.service.apibatchmember.emailvision.com/" xmlns:ns3="http://exceptions.service.apibatchmember.emailvision.com/"> <return>Dqaqb-MJ9V_eplZ8fPh4tdHUbxM-ZtuZsDG6galAGZSfSzyxgtuuIxZc3aSsnhI4b0SCbJsZmrZ_d3v2-7G8</return> </ns2:openApiConnectionResponse> </soap:Body> </soap:Envelope> --uuid:af66440a-012e-4444-8814-895c843de5ec--''.
就像前面的例子一样;我们有一个有效的soap响应,并且调用成功,但客户端似乎对内容类型有问题,并产生了异常。
有没有我可以设置的选项,所以客户端没有响应类型的问题?我已经做了一些谷歌的搜索,但我发现没有什么帮助我到目前为止。
解决方法
以下是所需配置设置的代码段:
<configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding messageEncoding="Mtom"> </binding> </basicHttpBinding> </bindings> </system.serviceModel> </configuration>
编辑:如果您有与自定义绑定相同的问题,请参阅answer from @robmzd。
我仍然没有找到一个解决方案来消费它作为一个旧式的Web引用。
2 pieces of AFE papers——initiation,Alternative Promoters(both for the first exon splice)
---恢复内容开始---
《A paired-end sequencing strategy to map the complex landscape of transcription initiation》
《Tissue-Specific and Ubiquitous Expression Patterns from Alternative Promoters of Human Genes》
第一篇:来自nature method
用的是果蝇的胚胎RNASeq数据分析了其TSS部位的initiation landscape,也就是本人所感兴趣的AFE,在哺乳动物体内也发现了可以用特定motif表征的相似的启动子部位特征。再有,他们发现了5‘帽子端的转录起源于编码的外显子,从本文章中看来,他们的发现TSS的存在并不是形成转录本的过程中选择性剪切的结果,而是转录前的基因coding region的改造作用所产生的产物,证明了paired-end tss analysis to be a powerful method to uncover the transcriptional complexity of eukaryotic genomes.
其中想说的是作者的开篇:
recent studies using high-throughput sequencing protocols have uncovered the complexity of mammalian transcription by rnA polymerase ii,helping to de ne several initiation patterns in which transcription start sites (tsss) cluster in both narrow and broad genomic windows.
key words:
TSS:Central to this process is the core promoter region of ~100 nucleotides (nt) surrounding the transcription start site (TSS) of a gene
TSS区域的作用是其间DNA motif sequence 保证了RNA转录酶的召集,从而启动转录,
CAGE:the capped analysis of gene expres-sion (CAGE) protocol has been used to generate comprehensive
mammalian libraries of short sequence tags,(CAGE的一般作用)which have led to the identification of distinct transcription initiation patterns
TATA Box:an over- representation of the canonical TATA Box sequence motif in ‘single-peak’ promoters and CpG islands overlapping ‘broad range’ promoters
目前5‘端的seqing technology有CAGE protocol,deep CAGE protocol,PEAT(本篇作者团队开发的,杜克大学药学院)
PEAT:paired--end analysis of TSSs
PEAT的strategy图示:RCA:rolling circle amplification(特色)
##########################
3′ reads were mostly mapped to coding regions of annotated genes,indicating the success of the paired-end library construction.