2013-01-17 108 views
-1

我目前正在编写一个与SOAP Web服务交互的WCF客户端。 我的问题是,我的响应对象始终为零,即使是简单的类型。 没有发生异常。为什么响应对象中的所有项都为空?

WSDL位置:https://sandbox-soap.billsafe.de/wsdl/V209

THX 4帮助!

的App.config

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.diagnostics> 
     <sources> 
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose,ActivityTracing"> 
       <listeners> 
        <add type="System.Diagnostics.DefaultTraceListener" name="Default"> 
         <filter type="" /> 
        </add> 
        <add name="BillSAFESServiceMessageLoggingListener"> 
         <filter type="" /> 
        </add> 
       </listeners> 
      </source> 
     </sources> 
     <sharedListeners> 
      <add initializeData="BillSAFE.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
       name="BillSAFESServiceMessageLoggingListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"> 
       <filter type="" /> 
      </add> 
     </sharedListeners> 
    </system.diagnostics> 
    <system.serviceModel> 
     <behaviors> 
      <endpointBehaviors> 
       <behavior name="BillSAFEServiceBehavior"> 
        <callbackDebug includeExceptionDetailInFaults="true" /> 
       </behavior> 
      </endpointBehaviors> 
     </behaviors> 
     <bindings> 
      <customBinding> 
       <binding name="BillSAFEServiceBinding" receiveTimeout="00:01:00"> 
        <textMessageEncoding messageVersion="Soap11" /> 
        <httpsTransport /> 
       </binding> 
      </customBinding> 
     </bindings> 
     <client> 
      <endpoint address="https://sandbox-soap.billsafe.de/V209" behaviorConfiguration="BillSAFEServiceBehavior" 
       binding="customBinding" bindingConfiguration="BillSAFEServiceBinding" 
       contract="BillSAFE.V209.IBillSAFEService" name="BillSAFEServiceSandbox" 
       kind="" endpointConfiguration="" /> 
     </client> 
     <diagnostics performanceCounters="Default"> 
      <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true" 
       logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /> 
     </diagnostics> 
    </system.serviceModel> 
</configuration> 

IBillSAFEService.cs

[ServiceContract(Namespace = "urn:BillSAFE")] 
public interface IBillSAFEService 
{ 
    [OperationContract(Name = "getAgreedHandlingCharges"/*, Action = "urn:BillSAFEAction", ReplyAction = "*"*/)] 
    GetAgreedHandlingChargesResponse GetAgreedHandlingCharges(GetAgreedHandlingChargesRequest request); 

    [OperationContract(Name = "getAgreedHandlingCharges"/*, Action = "urn:BillSAFEAction", ReplyAction = "*"*/)] 
    Task<GetAgreedHandlingChargesResponse> GetAgreedHandlingChargesAsync(GetAgreedHandlingChargesRequest request); 
} 

BillSAFEServiceClient.cs

public class BillSAFEServiceClient : ClientBase<IBillSAFEService>, IBillSAFEService, IDisposable 
{ 
    public BillSAFEServiceClient(string endpointConfigurationName) 
     : base(endpointConfigurationName) 
    { 

    } 

    public GetAgreedHandlingChargesResponse GetAgreedHandlingCharges(GetAgreedHandlingChargesRequest request) 
    { 
     try 
     { 
      return this.Channel.GetAgreedHandlingCharges(request); 
     } 
     catch (Exception) 
     { 
      throw; 
     } 
    } 

    public Task<GetAgreedHandlingChargesResponse> GetAgreedHandlingChargesAsync(GetAgreedHandlingChargesRequest request) 
    { 
     try 
     { 
      return this.Channel.GetAgreedHandlingChargesAsync(request); 
     } 
     catch (Exception) 
     { 
      throw; 
     } 
    } 
} 

GetAgreedHandlingChargesRequest.cs

[MessageContract(WrapperName = "getAgreedHandlingChargesRequest", WrapperNamespace = "urn:BillSAFE", IsWrapped = true)] 
public class GetAgreedHandlingChargesRequest : Request 
{ 

} 

GetAgreedHandlingChargesResponse.cs

[MessageContract(WrapperName = "getAgreedHandlingChargesResponse", WrapperNamespace = "urn:BillSAFE", IsWrapped = true)] 
public class GetAgreedHandlingChargesResponse : Response 
{ 
    [MessageBodyMember(Name = "agreedCharge", Namespace = "urn:BillSAFE")] 
    public ICollection<AgreedHandlingCharge> AgreedCharge { get; set; } 

    public GetAgreedHandlingChargesResponse() 
    { 
     this.AgreedCharge = new List<AgreedHandlingCharge>(); 
    } 
} 

Response.cs

[MessageContract(WrapperNamespace = "urn:BillSAFE", IsWrapped = true)] 
public abstract class Response 
{ 
    [MessageBodyMember(Name = "ack")] 
    public string Ack { get; set; } 

    [MessageBodyMember(Name = "errorList")] 
    public ICollection<Error> ErrorList { get; set; } 

    protected Response() 
    { 
     //this.Ack = V209.Ack.Error; 
     this.ErrorList = new List<Error>(); 
    } 
} 

Request.cs

[MessageContract(WrapperNamespace = "urn:BillSAFE", IsWrapped=true)] 
public abstract class Request 
{ 
    [MessageBodyMember(Name = "merchant", Namespace = "urn:BillSAFE")] 
    public Merchant Merchant { get; set; } 

    [MessageBodyMember(Name = "application", Namespace = "urn:BillSAFE")] 
    public Application Application { get; set; } 
} 

E2ETraceEvent(请求)

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"> 
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"> 
<EventID>0</EventID> 
<Type>3</Type> 
<SubType Name="Information">0</SubType> 
<Level>8</Level> 
<TimeCreated SystemTime="2013-01-17T20:54:31.1064522Z" /> 
<Source Name="System.ServiceModel.MessageLogging" /> 
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /> 
<Execution ProcessName="vstest.executionengine.x86" ProcessID="8812" ThreadID="8" /> 
<Channel /> 
<Computer>SEBASTIAN-PC</Computer> 
</System> 
<ApplicationData> 
<TraceData> 
<DataItem> 
<MessageLogTraceRecord Time="2013-01-17T21:54:31.1064522+01:00" Source="TransportSend" Type="System.ServiceModel.Dispatcher.OperationFormatter+OperationFormatterMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace"> 
<Addressing> 
<Action>urn:BillSAFE/IBillSAFEService/getAgreedHandlingCharges</Action> 
<To>https://sandbox-soap.billsafe.de/V209</To> 
</Addressing> 
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Header> 
<VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo4Y6WSDqKJ5EkZhFjJEu4DAAAAAAs2bp4OEOTEWhpHQOICljk07jg5xHVctBqgCzT6DCuOAACQAA</VsDebuggerCausalityData> 
</s:Header> 
<s:Body> 
<getAgreedHandlingChargesRequest xmlns="urn:BillSAFE"> 
<application xmlns:a="http://schemas.datacontract.org/2004/07/BillSAFE.V209" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<a:signature>###########</a:signature> 
<a:version>>###########</a:version> 
</application> 
<merchant xmlns:a="http://schemas.datacontract.org/2004/07/BillSAFE.V209" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<a:id>>###########</a:id> 
<a:license>>###########</a:license> 
</merchant> 
</getAgreedHandlingChargesRequest> 
</s:Body> 
</s:Envelope> 
</MessageLogTraceRecord> 
</DataItem> 
</TraceData> 
<System.Diagnostics xmlns="http://schemas.microsoft.com/2004/08/System.Diagnostics"> 
<LogicalOperationStack></LogicalOperationStack> 
<Timestamp>752163894457</Timestamp> 
<Callstack> 
bei System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) 
bei System.Environment.get_StackTrace() 
bei System.Diagnostics.TraceEventCache.get_Callstack() 
bei System.Diagnostics.XmlWriterTraceListener.WriteFooter(TraceEventCache eventCache) 
bei System.Diagnostics.XmlWriterTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) 
bei System.Diagnostics.TraceSource.TraceData(TraceEventType eventType, Int32 id, Object data) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLoggingSource source, Object data) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLogTraceRecord record) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogMessageImpl(Message& message, XmlReader reader, MessageLoggingSource source) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogMessage(Message& message, XmlReader reader, MessageLoggingSource source) 
bei System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Int32 maxMessageSize, BufferManager bufferManager, Int32 messageOffset) 
bei System.ServiceModel.Channels.HttpOutput.SerializeBufferedMessage(Message message) 
bei System.ServiceModel.Channels.HttpOutput.SendAsyncResult.SendWithoutChannelBindingToken() 
bei System.ServiceModel.Channels.HttpOutput.SendAsyncResult.Send() 
bei System.ServiceModel.Channels.HttpOutput.SendAsyncResult..ctor(HttpOutput httpOutput, HttpResponseMessage httpResponseMessage, Boolean suppressEntityBody, TimeSpan timeout, AsyncCallback callback, Object state) 
bei System.ServiceModel.Channels.HttpOutput.BeginSendCore(HttpResponseMessage httpResponseMessage, TimeSpan timeout, AsyncCallback callback, Object state) 
bei System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelAsyncRequest.SendWebRequest() 
bei System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelAsyncRequest.BeginSendRequest(Message message, TimeSpan timeout) 
bei System.ServiceModel.Channels.RequestChannel.BeginRequest(Message message, TimeSpan timeout, AsyncCallback callback, Object state) 
bei System.ServiceModel.Dispatcher.RequestChannelBinder.BeginRequest(Message message, TimeSpan timeout, AsyncCallback callback, Object state) 
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartSend(Boolean completedSynchronously) 
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishEnsureOpen(IAsyncResult result, Boolean completedSynchronously) 
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureOpen(Boolean completedSynchronously) 
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishEnsureInteractiveInit(IAsyncResult result, Boolean completedSynchronously) 
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureInteractiveInit() 
bei System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.Begin() 
bei System.ServiceModel.Channels.ServiceChannel.BeginCall(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, TimeSpan timeout, AsyncCallback callback, Object asyncState) 
bei System.ServiceModel.Channels.ServiceChannel.BeginCall(ServiceChannel channel, ProxyOperationRuntime operation, Object[] ins, AsyncCallback callback, Object asyncState) 
bei System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2,TArg3](Func`6 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, TArg3 arg3, Object state, TaskCreationOptions creationOptions) 
bei System.Threading.Tasks.TaskFactory`1.FromAsync[TArg1,TArg2,TArg3](Func`6 beginMethod, Func`2 endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, Object state) 
bei System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateGenericTask[T](ServiceChannel channel, ProxyOperationRuntime operation, Object[] inputParameters) 
bei System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateGenericTask(ServiceChannel channel, ProxyOperationRuntime operation, Object[] inputParameters) 
bei System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateTask(ServiceChannel channel, IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
bei System.ServiceModel.Channels.ServiceChannelProxy.InvokeTaskService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
bei System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
bei BillSAFE.V209.IBillSAFEService.GetAgreedHandlingChargesAsync(GetAgreedHandlingChargesRequest request) 
bei BillSAFE.V209.BillSAFEServiceClient.GetAgreedHandlingChargesAsync(GetAgreedHandlingChargesRequest request) in d:\Eigene Dokumente\Visual Studio 2012\Projects\BillSAFEManager\BillSAFE\V209\BillSAFEServiceClient.cs:Zeile 149. 
bei BillSAFE.UnitTest.BillSAFEServiceClientUnitTest.<GetAgreedHandlingChargesAsyncTestMethod>d__2.MoveNext() in d:\Eigene Dokumente\Visual Studio 2012\Projects\BillSAFEManager\BillSAFE.UnitTest\BillSAFEServiceClientUnitTest.cs:Zeile 67. 
bei System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) 
bei System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine) 
bei BillSAFE.UnitTest.BillSAFEServiceClientUnitTest.GetAgreedHandlingChargesAsyncTestMethod() 
bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) 
bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) 
bei System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) 
bei Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.DefaultTestMethodInvoke(Object[] args) 
bei Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.RunTestMethod() 
bei Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.ExecuteTest(TestExecutionOutputs testExecutionOutputs) 
bei Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.ExecuteInternal(TestExecutionOutputs testExecutionOutputs) 
bei Microsoft.VisualStudio.TestPlatform.MSTestFramework.TestMethodRunner.Execute() 
bei Microsoft.VisualStudio.TestPlatform.MSTestFramework.UnitTestRunner.RunInternal(TestMethod testMethod, Boolean isDataDriven) 
bei Microsoft.VisualStudio.TestPlatform.MSTestFramework.UnitTestRunner.RunSingleTest(String name, String fullClassName, Boolean isAsync) 
</Callstack> 
</System.Diagnostics> 
</ApplicationData> 
</E2ETraceEvent> 

E2ETraceEvent(响应)

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"> 
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system"> 
<EventID>0</EventID> 
<Type>3</Type> 
<SubType Name="Information">0</SubType> 
<Level>8</Level> 
<TimeCreated SystemTime="2013-01-17T20:54:31.5263682Z" /> 
<Source Name="System.ServiceModel.MessageLogging" /> 
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /> 
<Execution ProcessName="vstest.executionengine.x86" ProcessID="8812" ThreadID="12" /> 
<Channel /> 
<Computer>SEBASTIAN-PC</Computer> 
</System> 
<ApplicationData> 
<TraceData> 
<DataItem> 
<MessageLogTraceRecord Time="2013-01-17T21:54:31.5253905+01:00" Source="TransportReceive" Type="System.ServiceModel.Channels.BufferedMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace"> 
<HttpResponse> 
<StatusCode>OK</StatusCode> 
<StatusDescription>OK</StatusDescription> 
<WebHeaders> 
<Connection>close</Connection> 
<Vary>Accept-Encoding</Vary> 
<Content-Encoding></Content-Encoding> 
<Content-Length>241</Content-Length> 
<Content-Type>text/xml; charset=utf-8</Content-Type> 
<Date>Thu, 17 Jan 2013 20:54:31 GMT</Date> 
<Server>Apache</Server> 
</WebHeaders> 
</HttpResponse> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:BillSAFE"> 
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Header> 
<SOAP-ENV:Body> 
<ns1:getAgreedHandlingChargesResponse> 
<ack xmlns="">ERROR</ack> 
<errorList xmlns=""> 
<code>305</code> 
<message>No data to return</message> 
</errorList> 
</ns1:getAgreedHandlingChargesResponse> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 
</MessageLogTraceRecord> 
</DataItem> 
</TraceData> 
<System.Diagnostics xmlns="http://schemas.microsoft.com/2004/08/System.Diagnostics"> 
<LogicalOperationStack></LogicalOperationStack> 
<Timestamp>752164731996</Timestamp> 
<Callstack> 
bei System.Environment.GetStackTrace(Exception e, Boolean needFileInfo) 
bei System.Environment.get_StackTrace() 
bei System.Diagnostics.TraceEventCache.get_Callstack() 
bei System.Diagnostics.XmlWriterTraceListener.WriteFooter(TraceEventCache eventCache) 
bei System.Diagnostics.XmlWriterTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data) 
bei System.Diagnostics.TraceSource.TraceData(TraceEventType eventType, Int32 id, Object data) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLoggingSource source, Object data) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogInternal(MessageLogTraceRecord record) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogMessageImpl(Message& message, XmlReader reader, MessageLoggingSource source) 
bei System.ServiceModel.Diagnostics.MessageLogger.LogMessage(Message& message, XmlReader reader, MessageLoggingSource source) 
bei System.ServiceModel.Channels.HttpInput.ProcessHttpAddressing(Message message) 
bei System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.BeginParse() 
bei System.ServiceModel.Channels.HttpInput.BeginParseIncomingMessage(HttpRequestMessage httpRequestMessage, AsyncCallback callback, Object state) 
bei System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelAsyncRequest.ProcessResponse(HttpWebResponse response, WebException responseException) 
bei System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) 
bei System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelAsyncRequest.OnGetResponse(IAsyncResult result) 
bei System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result) 
bei System.Net.LazyAsyncResult.Complete(IntPtr userToken) 
bei System.Net.ContextAwareResult.CompleteCallback(Object state) 
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
bei System.Net.ContextAwareResult.Complete(IntPtr userToken) 
bei System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) 
bei System.Net.HttpWebRequest.ProcessResponse() 
bei System.Net.HttpWebRequest.SetResponse(CoreResponseData coreResponseData) 
bei System.Net.HttpWebRequest.SetAndOrProcessResponse(Object responseOrException) 
bei System.Net.ConnectionReturnResult.SetResponses(ConnectionReturnResult returnResult) 
bei System.Net.Connection.ReadComplete(Int32 bytesRead, WebExceptionStatus errorStatus) 
bei System.Net.Connection.ReadCallback(IAsyncResult asyncResult) 
bei System.Net.Connection.ReadCallbackWrapper(IAsyncResult asyncResult) 
bei System.Net.LazyAsyncResult.Complete(IntPtr userToken) 
bei System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) 
bei System.Net.Security._SslStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) 
bei System.Net.Security._SslStream.ReadFrameCallback(AsyncProtocolRequest asyncRequest) 
bei System.Net.AsyncProtocolRequest.CompleteRequest(Int32 result) 
bei System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes) 
bei System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult) 
bei System.Net.LazyAsyncResult.Complete(IntPtr userToken) 
bei System.Net.ContextAwareResult.CompleteCallback(Object state) 
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
bei System.Net.ContextAwareResult.Complete(IntPtr userToken) 
bei System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken) 
bei System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped) 
bei System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) 
</Callstack> 
</System.Diagnostics> 
</ApplicationData> 
</E2ETraceEvent> 

测试方法

[TestMethod] 
    public async Task GetAgreedHandlingChargesAsyncTestMethod() 
    { 
     using (BillSAFEServiceClient serviceClient = new BillSAFEServiceClient("BillSAFEServiceSandbox")) 
     { 
      try 
      { 
       GetAgreedHandlingChargesResponse response = await serviceClient.GetAgreedHandlingChargesAsync(new GetAgreedHandlingChargesRequest() 
       { 
        Merchant = this.GetMerchant(), 
        Application = this.GetApplication() 
       }); 

       if (response.Ack == "") 
       { 

       } 
      } 
      catch (Exception) 
      { 
       throw; 
      } 
     } 
    } 

@Alan

[DataContract(Name = "getAgreedHandlingChargesRequest")] 
[MessageContract(WrapperName = "getAgreedHandlingChargesRequest", WrapperNamespace = "urn:BillSAFE", IsWrapped = true)] 
public class GetAgreedHandlingChargesRequest : Request 
{ 

} 

[DataContract(Name = "getAgreedHandlingChargesResponse")] 
[MessageContract(WrapperName = "getAgreedHandlingChargesResponse", WrapperNamespace = "urn:BillSAFE", IsWrapped = true)] 
public class GetAgreedHandlingChargesResponse : Response 
{ 
    #region Properties 

    /// <summary> 
    /// 
    /// </summary> 
    [DataMember(Name = "agreedCharge")] 
    [MessageBodyMember(Name = "agreedCharge", Namespace = "urn:BillSAFE")] 
    public ICollection<AgreedHandlingCharge> AgreedCharge { get; set; } 

    #endregion 

    #region Constructor 

    /// <summary> 
    /// 
    /// </summary> 
    public GetAgreedHandlingChargesResponse() 
    { 
     this.AgreedCharge = new List<AgreedHandlingCharge>(); 
    } 

    #endregion 
} 

[DataContract] 
[MessageContract(WrapperNamespace = "urn:BillSAFE", IsWrapped = true)] 
public abstract class Response 
{ 
    #region Properties 

    /// <summary> 
    /// 
    /// </summary> 
    [DataMember(Name = "ack")] 
    [MessageBodyMember(Name = "ack")] 
    public string Ack { get; set; } 

    /// <summary> 
    /// 
    /// </summary> 
    [DataMember(Name = "errorList")] 
    [MessageBodyMember(Name = "errorList")] 
    public ICollection<Error> ErrorList { get; set; } 

    #endregion 

    #region Constructor 

    /// <summary> 
    /// 
    /// </summary> 
    protected Response() 
    { 
     //this.Ack = V209.Ack.Error; 
     this.ErrorList = new List<Error>(); 
    } 

    #endregion 
} 

[DataContract] 
[MessageContract(WrapperNamespace = "urn:BillSAFE", IsWrapped=true)] 
public abstract class Request 
{ 
    #region Properties 

    /// <summary> 
    /// 
    /// </summary> 
    [DataMember(Name = "merchant")] 
    [MessageBodyMember(Name = "merchant", Namespace = "urn:BillSAFE")] 
    public Merchant Merchant { get; set; } 

    /// <summary> 
    /// 
    /// </summary> 
    [DataMember(Name = "application")] 
    [MessageBodyMember(Name = "application", Namespace = "urn:BillSAFE")] 
    public Application Application { get; set; } 

    #endregion 
} 

回答

0

在你的类:商人,应用程序,错误等添加[DataContract]类的声明和[DataMember]以上以上所有属性如下:

[DataContract] 
public class Merchant 
{ 
    [DataMember] 
    public int SomeVariable { get; set; } 

    ... 
} 

此外,我注意到您的MessageBodyMember名称和类名之间存在一些大小写差异,您是否尝试将它们更改为相同?

+0

这是行不通的。我已经测试过了吗?显示:http://msdn.microsoft.com/en-us/library/vstudio/ms751464(v=vs.90).aspx – Asesjix

+0

你可以发布一个你试图添加的例子吗? – alan

+0

显示@测试方法 – Asesjix

1

好吧,我刚刚发现错误,我再次看着只是XML响应。所有属性都没有名称空间。这必须具体说明。

SOAP响应

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:BillSAFE"> 
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"></s:Header> 
<SOAP-ENV:Body> 
<ns1:getAgreedHandlingChargesResponse> 
<ack xmlns="">ERROR</ack> 
<errorList xmlns=""> 
<code>305</code> 
<message>No data to return</message> 
</errorList> 
</ns1:getAgreedHandlingChargesResponse> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

C#

[MessageContract(WrapperNamespace = "urn:BillSAFE", IsWrapped = true)] 
public abstract class Response 
{ 
    #region Properties 

    /// <summary> 
    /// 
    /// </summary> 
    [MessageBodyMember(Name = "ack", Namespace = "")] 
    public Ack Ack { get; set; } 

    /// <summary> 
    /// 
    /// </summary> 
    [MessageBodyMember(Name = "errorList", Namespace = "")] 
    public ICollection<Error> ErrorList { get; set; } 

    #endregion 

    #region Constructor 

    /// <summary> 
    /// 
    /// </summary> 
    protected Response() 
    { 
     this.Ack = V209.Ack.Error; 
     this.ErrorList = new List<Error>(); 
    } 

    #endregion 
} 
+0

当你在它的时候,删除这些try/catch块。 'try {...} catch(Exception){throw;}'与'...'是一样的,但不会浪费太多时间。 –

相关问题