我必须使用我们的合作伙伴提供的服务.我得到了很少的指导,但被告知安全性是PasswordDigest.我查了一遍,立即看到了很多对WSE的引用,所以我离开了.它非常容易实现,并且我很快就使用了PasswordDigest的标准WSE用户令牌,该令牌位于我的消息的SOAP头中.
当我们今天开始测试时,我立刻被告知(通过错误消息)事情是不对的.事实证明,伙伴不会查看SOAP标头,而是希望http标头中的安全信息.
我已经看过很多关于如何将自定义http标头添加到代理类的文章,但是我的代理继承自SoapHttpClientProtocol,它没有要添加的标头集合.我正在考虑制作一个原始的httpWebRequest,但是我有一个特定的方法来访问它有一些复杂的参数来处理(而且它感觉就像回到正确的话).
将自定义http标头添加到没有GetWebRequest方法的服务代理类的最佳方法是什么?
以供参考:
代理类decleration:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.3053")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="MtomServiceSoap11", namespace="http://ws.xxxxxxx.com/")]
public partial class MtomServiceService : System.Web.Services.Protocols.SoapHttpClientProtocol {
Run Code Online (Sandbox Code Playgroud)
我需要调用的目标方法:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("uploadDocumentResponse", Namespace="http://ws.edsmtom.citizensfla.com/")]
public uploadDocumentResponse uploadDocument([System.Xml.Serialization.XmlElementAttribute(Namespace="http://ws.xxxxxxx.com/")] uploadDocumentRequest uploadDocumentRequest) {
object[] results = this.Invoke("uploadDocument", new object[] {
uploadDocumentRequest});
return ((uploadDocumentResponse)(results[0]));
}
}
Run Code Online (Sandbox Code Playgroud)
对服务的实际调用很简单.传入的对象不是:
request.criteria = docCriteria;
request.document = document;
var result = service.uploadDocument(request);
Run Code Online (Sandbox Code Playgroud)
谢谢.
为什么console.log(00);和console.log(01);打印0在浏览器控制台1,而不是00 01?
console.log(00); // prints 0;
console.log(01); // prints 1;
console.log(011); // prints 9;
console.log(0111); // prints 73;
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写LINQ查询以通过字符串值给定的动态属性来orderB。
这是我的原始代码:
Expression<Func<T, dynamic>> orderBy = i => i.GetType().GetProperty("PropertyName").GetValue(null);
Run Code Online (Sandbox Code Playgroud)
当我尝试运行此订单时,出现以下异常:
LINQ to Entities无法识别方法'System.Object GetValue(System.Object)',并且该方法无法转换为商店表达式。
我正在尝试通过创建将给我相同结果的表达式树来解决此问题。该代码应该能够根据参数返回任何类型,但是返回类型有麻烦。如果不转换该值,则会收到另一个错误消息,提示w Nullable DateTime无法转换为Object。这是我到目前为止的代码:
ParameterExpression pe = Expression.Parameter(typeof(T), "s");
Expression<Func<T, dynamic>> orderByExpression = Expression.Lambda<Func<T, dynamic>>(Expression.Convert(Expression.Property(pe, "PropertyName"), typeof(object)), pe);
Run Code Online (Sandbox Code Playgroud)
和我的新例外:
无法将类型'System.Nullable`1 [[System.DateTime]]'强制转换为类型'System.Object'。LINQ to Entities仅支持强制转换EDM基本类型或枚举类型。
我将如何编写此表达式树以返回动态类型?还有在LINQ中应该做的更好的方法吗?
c# linq linq-to-entities expression-trees entity-framework-6