channelfactory.endpoint上的address属性为null。 channelfactory的端点必须指定有效地址 [英] The address property on channelfactory.endpoint was null. The channelfactory's endpoint must have a valid address specified
问题描述
大家好,
Hi ALL,
I am getting the following error and I am not sure what I am doing wrong. Does anybody see anything obvious? Below are my project's Web.config and my reference link in code behind.
我的错误是:
My error is:
The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified.
我的web.config:
My web.config:
<system.serviceModel>
<services>
<service behaviorConfiguration="WcfService3._5.Service1Behavior"
name="WcfService3._5.Service1">
<endpoint address="" binding="basicHttpBinding" contract="WcfService3._5.IService1">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service behaviorConfiguration="WcfService3._5.LoginBehavior"
name="WcfService3._5.Login">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="WcfService3._5.ILogin">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:63460/Login"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WcfService3._5.Service1Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="WcfService3._5.LoginBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我的代码背后是:
使用System;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControls;
使用System.IO;
public partial class _Default:System.Web.UI.Page
{
protected void Page_Load(object sender,EventArgs e)< br $>
{
string res;
string strXmlRequest = string.Empty;
strXmlRequest =< root>< loginapi>< username> wsadmin< password> pass< sessionid> b5uwdafp4u5wkxmq0ksmqa55;
//将字符串转换为流
byte [ ] byteArray = System.Text.Encoding.UTF8.GetBytes(strXmlRequest);
MemoryStream stream = new MemoryStream(byteArray);
api5.LoginClient ap = new api5.LoginClient();
res = ap.POSTLogin(stream);
}
}
请给我一个解决方案。
提前感谢。
我尝试过:
My code behind is :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string res;
string strXmlRequest = string.Empty;
strXmlRequest = "<root><loginapi><username>wsadmin<password>pass<sessionid>b5uwdafp4u5wkxmq0ksmqa55";
// convert string to stream
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(strXmlRequest);
MemoryStream stream = new MemoryStream(byteArray);
api5.LoginClient ap = new api5.LoginClient();
res = ap.POSTLogin(stream);
}
}
Please drop me a solution for this.
thanks in advance.
What I have tried:
The Address property on ChannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a valid Address specified
推荐答案
您还没有为端点填充地址字段,您只需填充基址。检查下面的网址,你会明白我的意思。
WCF服务中基地址的用法是什么 - Stack Overflow [ ^ ]
You have not populated address field for endpoint, You just populated base address. Check below URL you will understand what I am referring to.
what is the use of base address in WCF service - Stack Overflow[^]
这篇关于channelfactory.endpoint上的address属性为null。 channelfactory的端点必须指定有效地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!