我在从经典 ASP 调用 WCF 服务中的方法时遇到问题。以下是服务和配置的代码:
服务
[ServiceContract(Namespace = "http://Plumtree.dartKW.PdfGenerator.Web")]
public interface IPdfGeneratorService
{
[OperationContract]
String GeneratePdf(String xml);
}
public class PdfGeneratorService : IPdfGeneratorService
{
#region IPdfGeneratorService Members
public String GeneratePdf(String xml)
{
return "hello";
}
#endregion
}
配置
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_PdfGenerator"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferPoolSize="2147483647"
transferMode="Buffered">
<readerQuotas
maxArrayLength="2147483647"
maxStringContentLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"
maxDepth="32" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="serviceBehavior"
name="Plumtree.dartKW.PdfGenerator.Web.PdfGeneratorService">
<endpoint binding="basicHttpBinding"
bindingName="BasicHttpBinding_PdfGenerator"
contract="Plumtree.dartKW.PdfGenerator.Web.IPdfGeneratorService" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我已经在 WCF 测试客户端中测试了上述方法,它工作正常。这是我的asp页面中的代码:
mexMonikerString = "service:mexAddress='http://localhost:51997/PdfGeneratorService.svc/mex'"
mexMonikerString = mexMonikerString + ", address='http://localhost:51997/PdfGeneratorService.svc'"
mexMonikerString = mexMonikerString + ", binding=basicHttpBinding"
mexMonikerString = mexMonikerString + ", bindingNamespace='http://tempuri.org/'"
mexMonikerString = mexMonikerString + ", contract=IPdfGeneratorService"
mexMonikerString = mexMonikerString + ", contractNamespace='http://Plumtree.dartKW.PdfGenerator.Web'"
dim service
service = GetObject(mexMonikerString)
每当我尝试这个时,我都会收到以下错误:
System.ServiceModel 错误“800401e4”
合约没有支持指定绑定的端点。
我尝试在名字对象中传递绑定配置名称BasicHttpBinding_PdfGenerator
,basicHttpBinding
但我得到了同样的错误。我也无法在网上找到任何其他有关此错误的示例。
任何帮助将不胜感激