0
我最近創建了一個WCF服務並希望將其與Silverlight應用程序一起使用。爲此,我使用了SlSvcUtil(Silverlight 4)來創建必要的客戶端類。 但對於每一個方法,這個工具生成一個請求,對象至極對所有參數的方法通常需要SLSvcUtil生成RequestObject
public System.IAsyncResult BeginDepartmentGetAll(DepartmentGetAllRequest request, System.AsyncCallback callback, object asyncState)
{
object[] _args = new object[1];
_args[0] = request;
System.IAsyncResult _result = base.BeginInvoke("DepartmentGetAll", _args, callback, asyncState);
return _result;
}
public System.IAsyncResult BeginDummy(DummyRequest request, System.AsyncCallback callback, object asyncState)
{
object[] _args = new object[1];
_args[0] = request;
System.IAsyncResult _result = base.BeginInvoke("Dummy", _args, callback, asyncState);
return _result;
}
性能的相應請求類是這樣的:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "Dummy", WrapperNamespace ="http://example.com/Namespace", IsWrapped = true)]
public partial class DummyRequest
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://example.com/Namespace", Order = 0)]
public string s;
public DummyRequest()
{
}
public DummyRequest(string s)
{
this.s = s;
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(WrapperName = "DepartmentGetAll", WrapperNamespace = "http://example.com/Namespace", IsWrapped = true)]
public partial class DepartmentGetAllRequest
{
public DepartmentGetAllRequest()
{
}
}
在類似的WCF項目中,這些方法使用Web服務方法的普通參數,而不使用請求對象。如何在沒有這些請求對象的情況下生成服務方法?