嘿伙计们,
我正在尝试使用Mono从我的Ubuntu主机访问托管在虚拟机(Windows 7)上的Web服务.
我可以导入wdsl文件并生成服务引用.我从正确访问webservice的其他工作客户端复制了App.config.
当我尝试使用System连接到webservice时;
namespace MonoTest
{
class MainClass
{
public static void Main (string[] args)
{
Console.WriteLine ("Hello World!");
TestServer.Service1Client client = new TestServer.Service1Client("Test");
Console.WriteLine(client.GetData(12));
Console.ReadLine();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
System.InvalidOperationException: Client endpoint configuration 'Test' was not found in 1 endpoints.
at System.ServiceModel.ChannelFactory.ApplyConfiguration (System.String endpointConfig) [0x00000] in <filename unknown>:0
at System.ServiceModel.ChannelFactory.InitializeEndpoint (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
at System.ServiceModel.ChannelFactory`1[MonoTest.TestServer.IService1]..ctor (System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] in <filename unknown>:0
at System.ServiceModel.ClientBase`1[MonoTest.TestServer.IService1].Initialize (System.ServiceModel.InstanceContext instance, System.String endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) [0x00000] …Run Code Online (Sandbox Code Playgroud) 我有需要通过basicHTTPBinding进行通信的手持设备.我有合同,一切都按照广告宣传.
我需要扩展它以便轻松支持转换到测试环境,培训和生产.我采用了端口路由,认为我可以通过端口差异暴露不同的端点,并根据端口,决定我想要信息的数据库.
我似乎无法使这项工作,到目前为止,没有任何信息表明它可以完成.由于端口是可选的,因此可能不是.
有人做过这样的事吗?
我只是想尝试使用WCF,如果有人能告诉我我是否对端点有正确的想法,我就会徘徊.
我一直在处理msdn上的视频,现在我正在徘徊配置WCF服务的方式.场景是如果我有多个IServices,例如我有一个IThis和IThat,并且客户端需要访问权限(注意:他们将使用net.tcp),
它处理数据库查询,
IThat处理独立于数据库的计算,
我假设我必须为IThis和IThat定义单独的端点,这些端点在客户端中单独引用.或者我是否会创建一个在客户端中引用并包含两者功能的整体IThisAndThat服务?
或者是使用多个IServices开发和处理WCF服务的其他方法?虽然我问你能为tcp定义基地址还是只定义http?
〜谢谢大家,任何帮助或指针都会很棒.
如何编写具有单个端点但具有多个服务合同的WCF Web服务?
例:
[ServiceContract]
public interface IWirelessService
{
[OperationContract]
void AddWireless();
}
[ServiceContract]
public interface IWiredService
{
[OperationContract]
void AddWired();
}
[ServiceContract]
public interface IInternetService
{
[OperationContract]
void AddInternet();
}
Run Code Online (Sandbox Code Playgroud)
让我们认为IInternetService是我的主要Web服务,我想在其中实现IwiredService和IWirelessService,但我想在他们的类中实现.这可能吗?我怎么解决这个问题?
我有许多WCF服务,IIS在专用服务器上运行.这些服务有他们的客户.总而言之,它可以工作,但每当我在客户端级别查找日志时,我通常会看到以下类型的错误:
System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at <Service URL> that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
---> System.Net.WebException: Unable to connect to the remote server
---> System.Net.Sockets.SocketException: A socket operation was attempted to an unreachable network <Service IP>:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我不太确定它是如何开始的。我相当肯定它以前运行良好,但不记得进行任何更改。
首先,请不要过多关注设置,除非它直接影响了它不工作的原因。我不是在寻求批评,而是因为我是导致它不起作用的原因。
我正在公开一个使用 HTTP 标头身份验证的 API。我在我的解决方案中使用这个 API 的操作。为了避免样板代码,我创建了一个ClientFactory来初始化服务,使用CustomClientMessageInspector和CustomCredentialBehavior负责将标头添加到消息中。
这个想法是,当我需要使用服务时,代码看起来类似于:
IClientCredentials credentials = ClientCredentials.FromToken();
var service = ClientFactory.CreateClientInstance<API.Clients.ClientServiceClient>(credentials);
Run Code Online (Sandbox Code Playgroud)
ClientFactory 看起来像下面这样(请不要过度判断)。
public class ClientFactory
{
public static T CreateClientInstance<T>(IClientCredentials clientCredentials)
{
T t = Activator.CreateInstance<T>();
var factory = t.GetType().GetProperty("ChannelFactory");
using (var scope = new OperationContextScope((IContextChannel) t.GetType().GetProperty("InnerChannel").GetValue(t,null)))
{
var endpointBehavior = new CustomCredentialBehavior(clientCredentials);
if (((ChannelFactory) factory.GetValue((t),null)).Endpoint.Behaviors.Any(p => p.GetType() == typeof(CustomCredentialBehavior)))
{
var behavior =
((ChannelFactory) factory.GetValue((t),null)).Endpoint.Behaviors.FirstOrDefault(
p => p.GetType() == typeof (CustomCredentialBehavior));
((ChannelFactory) factory.GetValue((t),null)).Endpoint.Behaviors.Remove(behavior);
}
((ChannelFactory)factory.GetValue((t),null)).Endpoint.Behaviors.Add(endpointBehavior);
return …Run Code Online (Sandbox Code Playgroud) 所以这是我的问题.我有一个在服务中使用的客户端,当我使用Visual Studio中的内置测试主机测试所述服务时,所有服务合同都可用.但是,当我尝试测试其中一个服务合同时,Visual studio会发出以下错误
无法在ServiceModel客户端配置部分中找到引用合同"TestServiceReference.ITestService"的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.
现在,我知道立即和明显的答案是检查我的配置以确保我的端点是正确的,但这是事情,它是正确的.我检查了实现客户端的服务的web.config和客户端的app.config.两个端点都是正确的(至少我认为它们是正确的).
这是web.config端点:
<endpoint address="http://testServiceRepo/TestServices/TestService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService"
contract="TestServiceReference.ITestService"
name="BasicHttpBinding_ITestService" />
Run Code Online (Sandbox Code Playgroud)
这是app.config端点:
<endpoint address="http://testServiceRepo/TestServices/TestService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService"
contract="TestServiceReference.ITestService"
name="BasicHttpBinding_ITestService" />
Run Code Online (Sandbox Code Playgroud)
端点完全相同,它们都引用TestServiceReference.ITestService.所以,我在这里不知所措.你们会建议什么?
谢谢你的帮助!
当我使用Live WCF服务时,它显示错误
没有端点可以接受该消息.这通常是由错误的地址或SOAP操作引起的
我有一个WCF服务,我在客户端应用程序中连接.我在配置文件中使用以下.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyNameSpace.TestService" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:9100/TestService" binding="basicHttpBinding"
bindingConfiguration="MyNameSpace.TestService" contract="TestService.IService" name="MyNameSpace.TestService" />
</client>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
在代码中,我在此服务上调用API,如下所示,
TestServiceClient client = new TestServiceClient()
client.BlahBlah()
Run Code Online (Sandbox Code Playgroud)
现在我想用porgramatically定义端点.怎么办?我在配置文件中注释掉了部分,因为我认为我必须在TestServiceClient实例上放置一些代码来动态添加端点,然后在实例化TestServiceClient时抛出异常.
无法在ServiceModel客户端配置部分中找到引用合同"TestService.IService"的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.
我怎么能做到这一点?此外,以编程方式添加端点的代码示例的任何一点都将受到赞赏.
我需要这样的场景:客户端向服务器发送消息,而不是等待响应,如果消息发送正确,则不关心.
using(host.RemoteService client = new host.RemoteService())
{
client.Open();
cliend.SendMessage("msg");
}
Run Code Online (Sandbox Code Playgroud)
在防火墙打开或没有连接到Internet的情况下,客户端在"SendMessage"处死亡.我的意思是程序停止响应.我希望程序不关心结果.我的意思是如果没有连接,我希望程序更进一步,省略"SendMessage"或者像那样.
我该怎么办,有非阻塞方法的解决方案吗?
wcf ×10
wcf-endpoint ×10
c# ×6
.net ×4
soap ×2
asp.net ×1
endpoint ×1
linux ×1
mono ×1
soap-client ×1
web-services ×1