我正在尝试为生成的wcf 4.0 web配置添加一些我的服务的绑定配置。 出于某种原因,在我将服务发布到IIS并登录到服务wsdl后,我仍然看到旧的配置(basicHttpBinding而不是wsHttpBinding)。
这是我的代码:
的Web.Config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="PDFServiceBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="PDFService">
<endpoint address="http://localhost/PDFService/PDFService.svc"
binding="wsHttpBinding" bindingConfiguration="PDFServiceBinding"
contract="PDF.Service.IPDFService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/PDFService/" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
PDFService.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.IO;
namespace PDF.Service
{
public class PDFService : IPDFService
{
...
}
}
IPDFService.cs
namespace PDF.Service
{
[ServiceContract]
public interface IPDFService
{
...
}
}
发布后的wsdl:
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions name="PDFService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:tns="http://tempuri.org/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
- <wsdl:types>
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://localhost/PDFService/PDFService.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://localhost/PDFService/PDFService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="http://localhost/PDFService/PDFService.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/PDF" />
</xsd:schema>
</wsdl:types>
- <wsdl:message name="IPDFService_Save_InputMessage">
<wsdl:part name="parameters" element="tns:Save" />
</wsdl:message>
- <wsdl:message name="IPDFService_Save_OutputMessage">
<wsdl:part name="parameters" element="tns:SaveResponse" />
</wsdl:message>
- <wsdl:portType name="IPDFService">
- <wsdl:operation name="Save">
<wsdl:input wsaw:Action="http://tempuri.org/IPDFService/Save" message="tns:IPDFService_Save_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IPDFService/SaveResponse" message="tns:IPDFService_Save_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="BasicHttpBinding_IPDFService" type="tns:IPDFService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="Save">
<soap:operation soapAction="http://tempuri.org/IPDFService/Save" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="PDFService">
- <wsdl:port name="BasicHttpBinding_IPDFService" binding="tns:BasicHttpBinding_IPDFService">
<soap:address location="http://localhost/PDFService/PDFService.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
答案 0 :(得分:1)
您的服务元素应如下所示:
<service name="PDF.Service.PDFService">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PDFServiceBinding" contract="PDF.Service.IPDFService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
注意:您缺少在服务名称中提供命名空间。服务名称应完全合格。