我和同事正在讨论这个问题,我们无法达成协议,所以我想得到你的想法.我对此有自己的看法,但我不会为你破坏它.
我应该何时返回SOAP错误,何时应返回具有错误信息的结果对象?假设这是一个可以被各种系统(.NET,Java,等等)使用的通用Web服务.结果对象将具有isError标志,errorType(类似于特定的异常类型)和消息.
有些要考虑的要点:
文章链接有效.即使听起来我想要你的意见,请坚持事实(因为y和z,x更好)
我想查询XDocument
给定路径的对象,(例如"/ path/to/element/I/want")但我不知道如何继续.
我想禁用应用程序池的空闲超时(将其设置为零),我想在设置时执行此操作,是否可以从C#或PowerShell执行此操作?
我的合同定义如下:
[OperationContract]
[WebGet(UriTemplate = "/GetX?myStr={myStr}&myX={myX}", BodyStyle = WebMessageBodyStyle.Wrapped)]
string GetX(string myStr, int? myX);
Run Code Online (Sandbox Code Playgroud)
我得到一个例外:[InvalidOperationException:合同'IMyGet'中的'GetX'操作有一个名为'myX'的类型为'System.Nullable 1[System.Int32]', but type 'System.Nullable
1 [System.Int32]' 的查询变量'不能被'QueryStringConverter'转换.UriTemplate查询值的变量必须具有可由"QueryStringConverter"转换的类型.
找不到任何有关此错误的信息,除了以下链接:http: //blog.rolpdog.com/2007/07/webget-and-webinvoke-rock.html这有点旧,而不是解决方案.
任何想法除了摆脱可以为空的参数做什么?
谢谢.
在C#中,当泛型列表仅包含基类时,访问派生类的属性的最佳方法是什么.
public class ClassA : BaseClass
{
public object PropertyA { get; set; }
}
public class ClassB: BaseClass
{
public object PropertyB { get; set; }
}
public class BaseClass
{
}
public void Main
{
List<BaseClass> MyList = new List<BaseClass>();
ClassA a = new ClassA();
ClassB b = new ClassB();
MyList.Add(a);
MyList.Add(b);
for(int i = 0; i < MyList.Count; i++)
{
//I would like to access PropertyA abd PropertyB from the derived classes
}
}
Run Code Online (Sandbox Code Playgroud) 我可以使用菜单条或上下文菜单来允许用户,以便他可以在c#中更改窗口的背景图像而不是背景颜色吗?
历史
我基本上是一个前端(android)开发人员,从来没有必要创建一个Web服务而是我在消费端.现在这个WCF业务势不可挡,我认为学习曲线非常复杂.
任务
我需要创建一个简单的SOAP服务,hello world暂时需要输入XML,但是返回JSON.
我不知道为什么我们在互联网上没有类似的问题,有点让我想知道它是否根本不可能?
这就是我到目前为止所拥有的.
目前的进展
我的合同
[ServiceContract]
public interface IHelloWorldService
{
[OperationContract]
String GetMessage(String name);
}
Run Code Online (Sandbox Code Playgroud)
我的合同Impl
public string GetMessage(string name)
{
return "Hello World from " + name + "!";
}
Run Code Online (Sandbox Code Playgroud)
我的服务配置(在Web.Config中.我已经在asp.net网站上托管了这项服务)
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp defaultOutgoingResponseFormat="Json" />
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MyWcfServices.HelloWorldService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="" binding="wsHttpBinding" behaviorConfiguration="WebBehavior" contract="MyWcfServices.IHelloWorldService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
问题
我需要在WCF服务上进行自定义绑定,以允许我将原始内容传递给WCFRest服务.效果很好,但我不能让它接受传输级别的安全性.我想在其他地方使用https和basicauthentication.端点看起来像这样:
<endpoint address="" behaviorConfiguration="web" contract="SmsService.ISmsReceive" binding="customBinding" bindingConfiguration="RawReceiveCapable"></endpoint>
Run Code Online (Sandbox Code Playgroud)
customBinding看起来像这样:
<customBinding>
<binding name="RawReceiveCapable">
<security mode="Transport">
<transport clientCredentialType="Basic"/>
</security>
<webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
</binding>
</customBinding>
Run Code Online (Sandbox Code Playgroud)
但是系统抱怨安全节点中不允许使用mode属性.没有安全节点,一切都很好,但它不是https.
谢谢
射线
根据Microsoft有关配置参数的文档,".NET Framework数据提供程序处理命名并以不同方式指定参数和参数占位符".
@parametername
?
)指示的位置参数标记:parmname
(或parmname)的命名参数我正在编写方法来返回将用于参数化语句的SQL.如果我使用标准SQL,这些语句应该可以移植到各种各样的数据库中.如何创建通常有效的参数而不会从数据提供程序泄漏到SQL组件?
尝试在Visual Studio 2013中向ASP.NET Web应用程序添加服务引用时出现此错误.我在项目中引用了Microsoft.Owin.Security版本2.1.0.0.但是我很沮丧他为什么要寻找2.0.1.0版本?
无法导入wsdl:portType详细信息:运行WSDL导入扩展时抛出异常:System.ServiceModel.Description.DataContractSerializerMessageContractImporter错误:无法加载文件或程序集'Microsoft.Owin.Security,Version = 2.0.1.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'或其依赖项之一.该系统找不到指定的文件.
c# ×7
wcf ×4
.net ×2
rest ×2
web-services ×2
ado.net ×1
asp.net ×1
collections ×1
generics ×1
https ×1
iis ×1
linq ×1
linq-to-xml ×1
nullable ×1
oracleclient ×1
powershell ×1
soap ×1
soapfault ×1
sql ×1
transport ×1
wcf-binding ×1
winforms ×1
wsdl ×1
xml ×1
xpath ×1