试图让MTOM在WCF客户端中工作.我正在尝试使用的特定函数发送一个PDF文档的MTOM编码字节数组.使用SoapUI使用WSDL测试API工作正常; 但是,当我尝试在客户端中执行相同的操作时,我收到以下错误:
Error creating a reader for the MTOM message
System.Xml.XmlException: MTOM messages must have type 'application/xop+xml'.
at System.Xml.XmlMtomReader.ReadMessageContentTypeHeader(ContentTypeHeader he
ader, String& boundary, String& start, String& startInfo)
at System.Xml.XmlMtomReader.Initialize(Stream stream, String contentType, Xml
DictionaryReaderQuotas quotas, Int32 maxBufferSize)
at System.Xml.XmlMtomReader.SetInput(Stream stream, Encoding[] encodings, Str
ing contentType, XmlDictionaryReaderQuotas quotas, Int32 maxBufferSize, OnXmlDic
tionaryReaderClose onClose)
at System.Xml.XmlMtomReader.SetInput(Byte[] buffer, Int32 offset, Int32 count
, Encoding[] encodings, String contentType, XmlDictionaryReaderQuotas quotas, In
t32 maxBufferSize, OnXmlDictionaryReaderClose onClose)
at System.Xml.XmlDictionaryReader.CreateMtomReader(Byte[] buffer, Int32 offse
t, Int32 count, Encoding[] …Run Code Online (Sandbox Code Playgroud) 我是ES和Serilog的新手,但我的搜索尚未找到答案。我试图弄清楚如何使用Serilog以这样的方式将数据发送到Elasticsearch:如果数据包含字段(例如,如果它是具有公共属性的对象),则数据将在ES中以这些属性显示为领域。到目前为止,我已经得到了尽可能使用RenderedCompactJsonFormatter和匿名类型才能够做到这一点大部分(见下文),但仍可产生命名字段,其中字段中的数据是一切,但的“新”的一部分匿名类型声明:
var log = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://localhost:9200/test_srpostimes"))
{
InlineFields = true,
IndexDecider = (@event,offset) => "test_elapsedtimes",
CustomFormatter = new RenderedCompactJsonFormatter()
})
.WriteTo.Console()
.CreateLogger();
var elapsedTime = new {Time = 64};
var timeStamp = new {Timestamp = DateTime.Now};
var transID = new {TransID = "551674"};
log.Information("{timeStamp} {transID} {elapsedTime}", timeStamp, transID, elapsedTime);
Run Code Online (Sandbox Code Playgroud)
这将产生:
@t:
2016-07-11T18:45:35.0349343Z
@m:
"{ Timestamp = 7/11/2016 2:45:35 PM }" "{ TransID = 551674 }" "{ Time = 64 }"
@i:
b3ee2c05
timeStamp:
{ …Run Code Online (Sandbox Code Playgroud) I'm trying to find a way to only return the results of one aggregation in an Elasticsearch query. I have a max bucket aggregation (the one that I want to see) that is calculated from a sum bucket aggregation based on a date histogram aggregation. Right now, I have to go through 1,440 results to get to the one I want to see. I've already removed the results of the base query with the size: 0 modifier, but is there …
在没有使用方法递归或goto语句的情况下发生异常后,有没有简单的方法在try/catch块中重复代码?我正在调用一个Web服务,然后使用Entity Framework将该数据推送到SQL数据库,如果第一个步骤在第一个步骤成功后失败,我宁愿采用更简单或更简洁的方式重新尝试该步骤而不是递归相同的方法(这两个步骤在不同的方法中用于此目的)或使用goto语句.