Web services 找不到正确的WCF终结点配置
我创建了一个从安卓系统获取数据并保存到SQL中的服务。我正在使用iis7 我的代码:Web services 找不到正确的WCF终结点配置,web-services,wcf,endpoint,Web Services,Wcf,Endpoint,我创建了一个从安卓系统获取数据并保存到SQL中的服务。我正在使用iis7 我的代码: namespace WcfService_SuiviColis { // REMARQUE : vous pouvez utiliser la commande Renommer du menu Refactoriser pour changer le nom d'interface "IService1" à la fois dans le code et le fichier de configur
namespace WcfService_SuiviColis
{
// REMARQUE : vous pouvez utiliser la commande Renommer du menu Refactoriser pour changer le nom d'interface "IService1" à la fois dans le code et le fichier de configuration.
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat= WebMessageFormat.Json, BodyStyle =WebMessageBodyStyle.Wrapped, UriTemplate = "SaveData")]
void SaveData(Pers_Ordre_NET oData);
}
[DataContract]
public class Pers_Ordre_NET
{
[DataMember]
string _CodeClient;
public string CodeClient
{
get { return _CodeClient; }
set { _CodeClient = value; }
}
[DataMember]
string _CodeDest;
public string CodeDest
{
get { return _CodeDest; }
set { _CodeDest = value; }
}
[DataMember]
string _NoOrdre;
public string NoOrdre
{
get { return _NoOrdre; }
set { _NoOrdre = value; }
}
[DataMember]
string _DateTampon;
public string DateTampon
{
get { return _DateTampon; }
set { _DateTampon = value; }
}
[DataMember]
string _GeoPos;
public string GeoPos
{
get { return _GeoPos; }
set { _GeoPos = value; }
}
[DataMember]
string _StsOrdre;
public string StsOrdre
{
get { return _StsOrdre; }
set { _StsOrdre = value; }
}
[DataMember]
string _Camion;
public string Camion
{
get { return _Camion; }
set { _Camion = value; }
}
}
}
和service.svc.cs:
和web.config:
我得到错误400页找不到
我这样称呼我的方法:
<endpoint
address="SaveData" behaviorConfiguration="httpBehavior"
binding="webHttpBinding"
contract="WcfService_SuiviColis.IService1" />
<endpoint
address="" behaviorConfiguration="httpBehavior"
binding="webHttpBinding"
contract="WcfService_SuiviColis.IService1" />
<endpoint
address=""
binding="basicHttpBinding"
contract="WcfService_SuiviColis.IService1" />
http://mydomain:4004/Code/WcfService_SuiviColis/WcfService_SuiviColis/Service1.svc/SaveData
编辑
我认为正确的终点是:
<endpoint
address="" behaviorConfiguration="httpBehavior"
binding="webHttpBinding"
contract="WcfService_SuiviColis.IService1" />
但对于这个端点,我得到了错误405,不允许使用mmethod。是否可能不允许IIS 7将数据从ANDROID发送到服务器?
因为我已经用GET创建了另一个wcf程序,将数据从服务器发送到ANDROID,所以工作正常。乍一看,您定义的端点地址无效。它应该包含服务所在机器的完整地址以及端口号
<endpoint address ="http://mydomain:4004/...../>
因为您使用的是IIS,所以要使用的web URL基本上是由IIS定义的:您的服务器名称、虚拟目录的名称、*.svc文件的路径和位置 然后,在端点定义中可能会有一个额外的相对地址,因此如果使用
<endpoint
address="SaveData" behaviorConfiguration="httpBehavior"
binding="webHttpBinding"
contract="WcfService_SuiviColis.IService1" />
我不确定您是否需要向该URL添加另一个/SaveData,因为您已在服务合同中将其定义为您的UriTemplate:
http://YourWebServer/VirtualDirectory/Path/service.svc/SaveData/SaveData
++++++++ ********
| |
relative address |
from endpoint |
|
UriTemplate from your service contract
Endpoint not found通常表示您使用了错误的URL尝试访问您的服务。感谢您的响应,我这样做了,但我得到了erro 500,因为,然后我将其更改为false,但我得到了erro 400页面未找到
<endpoint address ="http://mydomain:4004/...../>
http://YourWebServer/VirtualDirectory/Path/service.svc
<endpoint
address="SaveData" behaviorConfiguration="httpBehavior"
binding="webHttpBinding"
contract="WcfService_SuiviColis.IService1" />
http://YourWebServer/VirtualDirectory/Path/service.svc/SaveData
http://YourWebServer/VirtualDirectory/Path/service.svc/SaveData/SaveData
++++++++ ********
| |
relative address |
from endpoint |
|
UriTemplate from your service contract