进行第一次WCF服务呼叫时出错

时间:2010-11-19 17:32:08

标签: wcf wcf-client

我正在为其中一个合作伙伴编写用于Java服务写入的WCF客户端。当我对他们的服务进行第一次服务调用时,我得到一个例外。但随后的请求没有抛出任何异常。我正在使用控制台应用程序来测试它。为什么第一次没有失败呢?

以下是我多次调用服务的代码

for (int i = 0; i < 3; i++)
{
   ServiceClientTest();
}

这是绑定代码

TransportBindingElement transportElement = null;
        transportElement = new HttpsTransportBindingElement();
        ((HttpsTransportBindingElement)transportElement).AuthenticationScheme = AuthenticationSchemes.Basic;

        var messegeElement = new TextMessageEncodingBindingElement
        {
            MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.None),
            ReaderQuotas =
                    {
                        MaxArrayLength = 200000,
                        MaxBytesPerRead = 200000,
                        MaxDepth = 200000,
                        MaxNameTableCharCount = 200000,
                        MaxStringContentLength = 200000
                    }
        };

        var binding = new CustomBinding(messegeElement, transportElement);
        return binding;

以下是第一次请求的例外细节

无法为CompanyXYZ ServiceCompany System.ServiceModel.CommunicationException获得分数:收到对https://test.intelligentcusomer.ServiceCompany.com/XYZCompanyAdapter/1.0的HTTP响应时发生错误。这可能是由于服务端点绑定不使用HTTP协议。这也可能是由于服务器中止HTTP请求上下文(可能是由于服务关闭)。请参阅服务器日志以获取更多详---&GT; System.Net.WebException:基础连接已关闭:接收时发生意外错误。 ---&GT; System.IO.IOException:无法从传输连接读取数据:已建立的连接已被主机中的软件中止。 ---&GT; System.Net.Sockets.SocketException:已建立的连接已被主机中的软件中止    在System.Net.Sockets.NetworkStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)    ---内部异常堆栈跟踪结束---    在System.Net.ConnectStream.Read(Byte []缓冲区,Int32偏移量,Int32大小)    在System.Net.HttpWebRequest.MakeMemoryStream(Stream stream)    ---内部异常堆栈跟踪结束---    在System.Net.HttpWebRequest.GetResponse()    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)    ---内部异常堆栈跟踪结束---

服务器堆栈跟踪:    在System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException,HttpWebRequest request,HttpAbortReason abortReason)    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)    在System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)    在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超时)    在System.ServiceModel.Channels.ServiceChannel.Call(String action,Boolean oneway,ProxyOperationRuntime operation,Object [] ins,Object [] outs,TimeSpan timeout)    在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime操作)    在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

在[0]处重新抛出异常:    在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)    在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData,Int32 type)    at MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapter.process(processRequest request)    在C:\ Projects \ MyCompany \ MyCompany.Distribution \ CustomDeliveryProcessor \ Clients \ XYZCompanyServiceClient.cs中的MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapterClient.MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapter.process(processRequest request):第1122行    在C:\ Projects \ MyCompany \ MyCompany.Distribution \ CustomDeliveryProcessor \ Clients \ XYZCompanyServiceClient.cs中的MyCompany.Services.Clients.ServiceCompany.XYZCompanyAdapterClient.process(进程process1):第1129行    在C:\ Projects \ MyCompany \ MyCompany.Distribution \ CustomDeliveryProcessor \ CusomerDelivery.cs中的CustomDeliveryProcessor.CusomerDelivery.CompanyTestTest():第131行

1 个答案:

答案 0 :(得分:3)