【发布时间】:2011-08-27 18:53:38
【问题描述】:
当我尝试使用我的服务时遇到以下错误。
There was no endpoint listening at http://myip:84/service1.svc/ that could accept the message. This is often caused by an incorrect address or SOAP action.
我的服务代码:
<system.serviceModel>
<services>
<service name="wcftest1.Service1" behaviorConfiguration="wcftest1.Service1Behavior">
<endpoint address="http://myip:84/Service1.svc/" behaviorConfiguration="epbeh" bindingConfiguration ="webConfig" binding="webHttpBinding" contract="wcftest1.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicConfig" >
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="webConfig">
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="wcftest1.Service1Behavior" >
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="wcftest1.validateUser, wcftest1"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="epbeh">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
服务类:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
服务接口:
[OperationContract]
[WebGet(ResponseFormat= WebMessageFormat.Json)]
string GetMsg();
客户端网络配置:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="WebHttpBinding_IService1">
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap12" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</textMessageEncoding>
<httpTransport/>
</binding>
</customBinding>
</bindings>
<client>
<endpoint binding="customBinding" address="http://myip:84/service1.svc/" bindingConfiguration="WebHttpBinding_IService1"
contract="ServiceReference1.IService1" name="WebHttpBinding_IService1" />
</client>
</system.serviceModel>
客户端代码:
ServiceReference1.Service1Client sc = new userwcftest1.ServiceReference1.Service1Client();
Response.Write(sc.GetData(5));
我的服务将由 PHP 开发人员使用,它基于 .NET 框架 3.5 构建,我将返回 JSON。 我是 WCF 的新手。
请帮帮我 谢谢
【问题讨论】:
-
如果您正在寻找基于 REST 的服务(因为您有 webhttpbinding),请查看 WCF REST starter kit。
-
@Aravind:谢谢你的建议……让我检查一下。
-
您在服务端有
Service1,在客户端有service1。我相信在.net 的某些部分中,URI 是区分大小写的。使它们相同。