WCF - 没有端点侦听net.tcp:// myserver:9000/SearchQueryService/Querier.svc可以接受该消息.
我在IIS应用程序上启用了net.tcp协议
Windows防火墙已关闭
对于整个IIS应用程序,net.tcp绑定设置为端口9000.
我的web.config非常标准:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="false"
logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
<service behaviorConfiguration="SearchQueryServiceBehavior"
name="Search.Querier.WCF.Querier">
<endpoint address="mex" binding="mexHttpBinding" name="mexHttpEndpoint"
contract="IMetadataExchange" />
<endpoint binding="netTcpBinding" bindingConfiguration=""
name="netTcpEndpoint"
contract="Search.Querier.WCF.IQuerier" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SearchQueryServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
这个设置在一台服务器上工作但不在另一台服务器上......可能是什么问题?
两台服务器,工作和非工作服务器都运行IIS7.唯一的区别是工作盒是Vista64 Sp2,而非工作盒是W2k864.
我花了两天时间试图解决这个问题而且我很难过.我有一个在Windows上作为服务运行的WCF服务器.客户端可以在同一台机器上连接到它,但是一旦我移动尝试连接到另一台机器上的服务我就不能.
因此,如果客户端和主机在同一台机器上,没有问题.如果主机和客户端位于不同的计算机上,则会出现异常错误.
这是奇怪的部分,我可以使用svcutil从远程机器生成app config和proxy.cs文件,但是一旦我调用该函数就会发出错误.
无法连接到net.tcp:// ipaddress:port/Service1.TCP错误代码10061.无法建立连接,因为目标计算机主动拒绝它.
如果我从同一台机器主机/客户端调用它没有错误.
有任何想法吗?
更新:
这是服务端点设置.
<system.serviceModel>
<services>
<service behaviorConfiguration="Service1Behavior" name="WcfServiceLibrary1.Service1">
<endpoint address="net.tcp://192.168.1.75:8523/Service1" binding="netTcpBinding"
contract="WcfServiceLibrary1.IService1" />
<endpoint address="net.tcp://192.168.1.75:8523/mex" binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://192.168.1.75:8523/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name = "TcpBindingConfiguration">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="Service1Behavior">
<serviceMetadata />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
我尝试了一切.
有任何想法吗?
再次是客户端和主机在同一台机器上一切都很好,只要我把客户端放在另一台计算机上,没有骰子......
白天我从未对网络编程感到头疼...
谢谢
我收到了以下错误
读取XML数据时已超出最大数组长度配额(16384).通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性,可以增加此配额.第1行,位置187231.描述:在执行当前Web请求期间发生了未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
例外细节:
System.Xml.XmlException:读取XML数据时已超出最大数组长度配额(16384).通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象上的MaxArrayLength属性,可以增加此配额.第1行,位置187231.
来源错误:
在执行当前Web请求期间生成了未处理的异常.可以使用下面的异常堆栈跟踪来识别有关异常的起源和位置的信息.
堆栈跟踪:
[XmlException: The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 187231.]
System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3) +311
System.Xml.XmlExceptionHelper.ThrowMaxArrayLengthExceeded(XmlDictionaryReader reader, Int32 maxArrayLength) +59
System.Xml.XmlBaseReader.ReadContentAsBase64() +1580759
System.Xml.XmlDictionaryReader.ReadElementContentAsBase64() +62
System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsBase64() +58
ReadPDFResponseFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] ) +525
System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context) …Run Code Online (Sandbox Code Playgroud) 我们有更多的wcf服务,并使用TCP绑定进行调用.在代码的不同位置有很多调用相同的wcf服务.
AdminServiceClient client = FactoryS.AdminServiceClient(); //需要很长时间.和
client.GetSomeThing(参数1); client.Close();
我想缓存客户端或从单身生成它.这样我可以节省一些时间,有可能吗?
谢谢
我试图更好地理解WCF的一些内部工作原理.我已经做了相当多的环顾四周,但是我无法找到ChannelFactory.Open()与之相比的明确解释IClientChannel.Open().开工厂的目的是什么?如果正在使用该通道进行通信,那么在创建和打开通道后,工厂将在该过程中播放哪个部分?
有人问在这里,其他的问题之一,但从来没有直接回答.
编辑:
在对源代码进行反编译之后,我发现了需要在ChannelFactory上调用Open的一些具体原因,如下所述.
我仍然无法理解的是,为什么这项工作是通过ICommunicationObject提供的机制完成的,当工厂实际上没有与任何东西进行通信时(据我所知).为什么不在构造或处理对象时处理这些事情?
我想我可能已经远远不够杂草,这样的答案可能无法公开.感谢那些权衡原始问题的人.
我已经在网上搜索了这方面的信息,但大多数结果都是关于创建WCF服务或服务在您控制之下的情况.
我正在为RESTful JSON服务构建一个WCF客户端代理,这是我无法控制的.我正在使用基本的ServiceContract/DataContract模式,并试图让框架尽可能多地完成工作.
大多数情况下,这工作正常,但来自此外部服务的所有日期时间字段都采用特定格式,例如
{"SomeObject":
{"details":"blue and round", "lastmodified":"2013/01/02 23:14:55 +0000"}
}
Run Code Online (Sandbox Code Playgroud)
所以我收到一个错误:
反序列化MyNamespace.SomeObject类型的对象时出错.DateTime内容'2013/01/02 23:14:55 +0000'不以'/ Date('和'以'结尾')开头,如JSON所示.'.
我的数据是:
namespace Marshmallow.WebServices.ServiceModels
{
[DataContract]
public class SomeObject
{
[DataMember(Name = "details")]
public string Details { get; set; }
[DataMember(Name = "lastmodified")]
public DateTime LastModified { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
我的服务合同是:
[ServiceContract]
public interface ICoolExternalApi
{
[OperationContract]
[WebGet(UriTemplate = "/something.json",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
[return: MessageParameter(Name = "SomeObject")]
SomeObject GetAccount();
}
Run Code Online (Sandbox Code Playgroud)
我想知道的是,在哪里可以添加一些代码来定义WCF如何反序列化lastmodified字段(从字符串中生成DateTime对象)?
或者更好的是,定义如何为所有DataContracts反序列化所有DateTime DataMembers.我不想要很多重复的代码.
我也不想求助于某些第三方反序列化器,也不想通过自定义反序列化方法开始放置其他所有内容,如果可以避免的话.
我在网上找到了我的问题的混合答案.详细说明问题:
我发现很多博主和论坛海报相互矛盾.任何人都可以指出任何明确的消息来源或证据来一劳永逸地回答这个问题吗?
我只是在学习WCF,尝试不同的东西.
我已经设置了以下服务:
[ServiceBehavior(IncludeExceptionDetailInFaults = true ,
InstanceContextMode = InstanceContextMode.Single)]
public class TestService : ITestService
{
// This operation is defined as OneWay.
public void Throws()
{
throw new ArgumentException();
}
}
Run Code Online (Sandbox Code Playgroud)
我从我的客户端使用它,如下所示:
var baseAddress = new Uri("net.pipe://localhost/hello");
// Create the ServiceHost.
using (ServiceHost host = new ServiceHost(typeof(TestService), baseAddress))
{
var netBinding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
host.AddServiceEndpoint(typeof(ITestService), netBinding, baseAddress);
host.Open();
Console.WriteLine("The service is ready at {0}", baseAddress);
// Create client channel.
var channel = ChannelFactory<ITestService>.CreateChannel(netBinding, new EndpointAddress(baseAddress));
((ICommunicationObject)channel).Open();
try
{
foreach (var …Run Code Online (Sandbox Code Playgroud) 我添加了对具有两个端点的WCF服务的引用.在添加服务时,以下内容将添加到Config文件中:
<client>
<endpoint name="ABCServiceV1" address="http://staging.ABCwebservices.com/ABC/Service.svc"
binding="basicHttpBinding" bindingConfiguration="ABCServiceV1"
contract="ABCService.IService" />
<endpoint name="ABCServiceV2" address="http://staging.ABCwebservices.com/ABC/Service.svc/20"
binding="basicHttpBinding" bindingConfiguration="ABCServiceV2"
contract="ABCService.IService1" />
</client>
Run Code Online (Sandbox Code Playgroud)
创建客户端的代码如下:
ABCService.ServiceClient ABCClient = new ServiceClient("ABCServiceV2");
Run Code Online (Sandbox Code Playgroud)
但是,我收到运行时错误 - "找不到名称为'ABCServiceV2'的端点元素,并在ServiceModel客户端配置部分中收缩'ABCService.IService'.这可能是因为找不到您的应用程序的配置文件,或者因为没有匹配此名称的端点元素可以在客户端元素中找到."
如果我使用ABCService.ServiceClient ABCClient = new ServiceClient("ABCServiceV1");然后一切正常.但是当使用ABCServiceV2时,它正在尝试寻找Contract - ABCService.IService - 它应该在什么时候寻找 - ABCService.IService1.
我如何让它寻找正确的合同?
wcf-client ×10
wcf ×8
c# ×4
.net ×3
binding ×1
datacontract ×1
datetime ×1
endpoints ×1
json ×1
silverlight ×1
wcf-binding ×1
wcf-proxy ×1
wcf-security ×1