2011-12-13 5 views
1

Я пытаюсь добавить в сгенерированную веб-конфигурацию wcf 4.0 некоторые конфигурации привязки для моего сервиса. По какой-то причине после публикации службы IIS и входа в службу wsdl я по-прежнему вижу старые конфигурации (basicHttpBinding вместо wsHttpBinding).Настройка привязки службы в wcf 4.0

Вот мой код:

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

Я попытался удалить приложение IIS и повторно опубликовать, но все же получил те же результаты. – ohadinho

+0

У меня нет ссылки на службы. Я просматриваю wsdl по адресу: http: //localhost/PDFService/PDFService.svc? Wsdl, и он не изменяется. – ohadinho

+0

Можете ли вы попытаться разместить это в локальном IIS и посмотреть, есть ли wsdl wsHttpBinding вместо BasicHttpBinding. Если в вашем локальном каталоге вы можете увидеть wsHttpBinding, я бы скопировал содержимое выходного каталога на удаленный сервер IIS, чтобы убедиться, что он не является проблемой во время публикации. – Rajesh

ответ

1

Ваш элемент услуг должен быть ниже:

<service name="PDF.Service.PDFService">   
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="PDFServiceBinding" contract="PDF.Service.IPDFService" />   
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />   
</service> 

Примечание: ваш отсутствуют, чтобы обеспечить пространство имен в вашем имени службы. Имя службы должно быть полностью квалифицированным.

Смежные вопросы