2012-08-23 19 views
0

我有一個ServiceLibrary應用程序(主機) - LTService這是我的應用程序的起點。它的合約接受三個參數username,password和xmlstring。驗證它後,我正在驗證和反序列化xmlstring。現在我有另一個ServiceLibrary應用程序(主機) - WCFServiceDialler暫時在同一個解決方案中。它接受一個用戶名,密碼和我從上面的反序列化xml過程中得到的對象。啓動應用程序無法找到客戶端WCF服務的端點配置

我讓我的客戶端在另一個Web應用程序中使用DiallerService prj - partnercontract在那裏我添加服務引用,它可以找到WCFServiceDialler公開的合同。但是,當我運行下面的代碼:

> LeadTransfer.PartnerContracts.DiallerServiceReference.DiallerClient 
> client = new 
> LeadTransfer.PartnerContracts.DiallerServiceReference.DiallerClient("wsHttpBinding"); 
>   WCFServiceDialler.DiallerData diallerData = new WCFServiceDialler.DiallerData(); 
>   diallerData.Username = "xxxx"; 
>   diallerData.Password = "xxx"; 
>   DiallerServiceReference.CarLeadDO temp = new DiallerServiceReference.CarLeadDO(); 
>   diallerData.carLeadDO = (DiallerServiceReference.CarLeadDO)Convert.ChangeType(tempDataMediator, 
> typeof(DiallerServiceReference.CarLeadDO)); 
>   client.DiallerProcess(diallerData); 

第一個語句拋出一個異常

無法與名字在ServiceModel客戶端配置「的wsHttpBinding」和合同「DiallerServiceReference.IDialler」找到終結點元素部分。這可能是因爲沒有爲您的應用程序找到配置文件,或者因爲在客戶端元素中找不到匹配此名稱的端點元素。

我無法弄清楚它無法找到端點。我的啓動應用程序都是上面的WCF服務項目。

以下是我的客戶服務applciation WSDL定義:

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 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" name="Service" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 
    <wsp:Policy wsu:Id="WSHttpBinding_IDialler_policy"> 
    <wsp:ExactlyOne> 
     <wsp:All> 
     <sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
      <wsp:Policy> 
      <sp:ProtectionToken> 
       <wsp:Policy> 
       <sp:SecureConversationToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> 
        <wsp:Policy> 
        <sp:RequireDerivedKeys /> 
        <sp:BootstrapPolicy> 
         <wsp:Policy> 
         <sp:SignedParts> 
          <sp:Body /> 
          <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" /> 
          <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" /> 
          <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
          <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
          <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" /> 
          <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
          <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" /> 
         </sp:SignedParts> 
         <sp:EncryptedParts> 
          <sp:Body /> 
         </sp:EncryptedParts> 
         <sp:SymmetricBinding> 
          <wsp:Policy> 
          <sp:ProtectionToken> 
           <wsp:Policy> 
           <sp:SpnegoContextToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient"> 
            <wsp:Policy> 
            <sp:RequireDerivedKeys /> 
            </wsp:Policy> 
           </sp:SpnegoContextToken> 
           </wsp:Policy> 
          </sp:ProtectionToken> 
          <sp:AlgorithmSuite> 
           <wsp:Policy> 
           <sp:Basic256 /> 
           </wsp:Policy> 
          </sp:AlgorithmSuite> 
          <sp:Layout> 
           <wsp:Policy> 
           <sp:Strict /> 
           </wsp:Policy> 
          </sp:Layout> 
          <sp:IncludeTimestamp /> 
          <sp:EncryptSignature /> 
          <sp:OnlySignEntireHeadersAndBody /> 
          </wsp:Policy> 
         </sp:SymmetricBinding> 
         <sp:Wss11> 
          <wsp:Policy /> 
         </sp:Wss11> 
         <sp:Trust10> 
          <wsp:Policy> 
          <sp:MustSupportIssuedTokens /> 
          <sp:RequireClientEntropy /> 
          <sp:RequireServerEntropy /> 
          </wsp:Policy> 
         </sp:Trust10> 
         </wsp:Policy> 
        </sp:BootstrapPolicy> 
        </wsp:Policy> 
       </sp:SecureConversationToken> 
       </wsp:Policy> 
      </sp:ProtectionToken> 
      <sp:AlgorithmSuite> 
       <wsp:Policy> 
       <sp:Basic256 /> 
       </wsp:Policy> 
      </sp:AlgorithmSuite> 
      <sp:Layout> 
       <wsp:Policy> 
       <sp:Strict /> 
       </wsp:Policy> 
      </sp:Layout> 
      <sp:IncludeTimestamp /> 
      <sp:EncryptSignature /> 
      <sp:OnlySignEntireHeadersAndBody /> 
      </wsp:Policy> 
     </sp:SymmetricBinding> 
     <sp:Wss11 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
      <wsp:Policy /> 
     </sp:Wss11> 
     <sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
      <wsp:Policy> 
      <sp:MustSupportIssuedTokens /> 
      <sp:RequireClientEntropy /> 
      <sp:RequireServerEntropy /> 
      </wsp:Policy> 
     </sp:Trust10> 
     <wsaw:UsingAddressing /> 
     </wsp:All> 
    </wsp:ExactlyOne> 
    </wsp:Policy> 
    <wsp:Policy wsu:Id="WSHttpBinding_IDialler_DiallerProcess_Input_policy"> 
    <wsp:ExactlyOne> 
     <wsp:All> 
     <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
      <sp:Body /> 
      <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" /> 
     </sp:SignedParts> 
     <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
      <sp:Body /> 
     </sp:EncryptedParts> 
     </wsp:All> 
    </wsp:ExactlyOne> 
    </wsp:Policy> 
    <wsp:Policy wsu:Id="WSHttpBinding_IDialler_DiallerProcess_output_policy"> 
    <wsp:ExactlyOne> 
     <wsp:All> 
     <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
      <sp:Body /> 
      <sp:Header Name="To" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="From" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="FaultTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="ReplyTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="MessageID" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="RelatesTo" Namespace="http://www.w3.org/2005/08/addressing" /> 
      <sp:Header Name="Action" Namespace="http://www.w3.org/2005/08/addressing" /> 
     </sp:SignedParts> 
     <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"> 
      <sp:Body /> 
     </sp:EncryptedParts> 
     </wsp:All> 
    </wsp:ExactlyOne> 
    </wsp:Policy> 
    <wsdl:types> 
    <xsd:schema targetNamespace="http://tempuri.org/Imports"> 
     <xsd:import schemaLocation="http://localhost:56435/Service.svc?xsd=xsd0" namespace="http://tempuri.org/" /> 
     <xsd:import schemaLocation="http://localhost:56435/Service.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" /> 
     <xsd:import schemaLocation="http://localhost:56435/Service.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/WCFServiceDialler" /> 
     <xsd:import schemaLocation="http://localhost:56435/Service.svc?xsd=xsd3" namespace="http://schemas.datacontract.org/2004/07/LeadTransfer.DiallerData.DataContracts.Car.Aviva" /> 
    </xsd:schema> 
    </wsdl:types> 
    <wsdl:message name="IDialler_DiallerProcess_InputMessage"> 
    <wsdl:part name="parameters" element="tns:DiallerProcess" /> 
    </wsdl:message> 
    <wsdl:message name="IDialler_DiallerProcess_OutputMessage"> 
    <wsdl:part name="parameters" element="tns:DiallerProcessResponse" /> 
    </wsdl:message> 
    <wsdl:portType name="IDialler"> 
    <wsdl:operation name="DiallerProcess"> 
     <wsdl:input wsaw:Action="http://tempuri.org/IDialler/DiallerProcess" message="tns:IDialler_DiallerProcess_InputMessage" /> 
     <wsdl:output wsaw:Action="http://tempuri.org/IDialler/DiallerProcessResponse" message="tns:IDialler_DiallerProcess_OutputMessage" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="WSHttpBinding_IDialler" type="tns:IDialler"> 
    <wsp:PolicyReference URI="#WSHttpBinding_IDialler_policy" /> 
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="DiallerProcess"> 
     <soap12:operation soapAction="http://tempuri.org/IDialler/DiallerProcess" style="document" /> 
     <wsdl:input> 
     <wsp:PolicyReference URI="#WSHttpBinding_IDialler_DiallerProcess_Input_policy" /> 
     <soap12:body use="literal" /> 
     </wsdl:input> 
     <wsdl:output> 
     <wsp:PolicyReference URI="#WSHttpBinding_IDialler_DiallerProcess_output_policy" /> 
     <soap12:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="Service"> 
    <wsdl:port name="WSHttpBinding_IDialler" binding="tns:WSHttpBinding_IDialler"> 
     <soap12:address location="http://localhost:56435/Service.svc/ws" /> 
     <wsa10:EndpointReference> 
     <wsa10:Address>http://localhost:56435/Service.svc/ws</wsa10:Address> 
     <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity"> 
      <Upn>[email protected]</Upn> 
     </Identity> 
     </wsa10:EndpointReference> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

配置爲第一lt服務應用:

<system.serviceModel> 
<services> 
    <service behaviorConfiguration="http" name="TestCDLWCF.Service"> 
    <endpoint address="wstest" binding="wsHttpBinding" contract="TestCDLWCF.ILeadTransfer"> 
     <identity> 
     <dns value="localhost" /> 
     </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8732/Design_Time_Addresses/TestCDLWCF/Service1/" /> 
     </baseAddresses> 
    </host> 
    </service> 
    <service name="WCFServiceDialler.Service"> 
    <endpoint address="ws" binding="wsHttpBinding" bindingConfiguration="" 
     contract="WCFServiceDialler.IDialler" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="http://localhost:8732/Design_Time_Addresses/WCFServiceDialler/Service/mex" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="http"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
    </behavior> 
    <behavior> 
     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
     <serviceMetadata httpGetEnabled="true"/> 
     <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
     <serviceDebug includeExceptionDetailInFaults="false"/> 
    </behavior> 

    </serviceBehaviors> 
</behaviors> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

配置爲WCFServiceDialler應用:

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="binding" /> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="WCFServiceDialler.Service"> 
     <endpoint address="ws" binding="wsHttpBinding" bindingConfiguration="binding" 
      contract="WCFServiceDialler.IDialler" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://localhost:8732/Design_Time_Addresses/WCFServiceDialler/Service/mex" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

配置在我的項目,消耗wcfdiallerservice:

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IDialler" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
       allowCookies="false"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" 
        enabled="false" /> 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="Windows" negotiateServiceCredential="true" 
         algorithmSuite="Default" /> 
       </security> 
      </binding> 
      <binding name="WSHttpBinding_IDialler1" closeTimeout="00:01:00" 
       openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
       bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
       maxBufferPoolSize="524288" maxReceivedMessageSize="65536" 
       messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" 
       allowCookies="false"> 
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
        maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
       <reliableSession ordered="true" inactivityTimeout="00:10:00" 
        enabled="false" /> 
       <security mode="Message"> 
        <transport clientCredentialType="Windows" proxyCredentialType="None" 
         realm="" /> 
        <message clientCredentialType="Windows" negotiateServiceCredential="true" 
         algorithmSuite="Default" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/Service.svc/ws" binding="wsHttpBinding" 
      bindingConfiguration="WSHttpBinding_IDialler" contract="WCFServiceDialler.IDialler" 
      name="WSHttpBinding_IDialler"> 
      <identity> 
       <servicePrincipalName value="host/CIDDTS4FCMG4.cis.ad.capita.co.uk" /> 
      </identity> 
     </endpoint> 
     <endpoint address="http://localhost:56435/Service.svc/ws" binding="wsHttpBinding" 
      bindingConfiguration="WSHttpBinding_IDialler1" contract="DiallerServiceReference.IDialler" 
      name="WSHttpBinding_IDialler1"> 
     </endpoint> 
    </client> 
</system.serviceModel> 
+0

你能也從德各自的web.config文件添加綁定配置? –

+0

@CoralDoe爲服務項目添加了兩個配置文件 –

+0

您的WCF服務是如何託管的? – Rajesh

回答

1

在服務客戶的同時,創建您的客戶端對象的實例,並傳遞一個端點應在您的配置文件中存在名稱:

LeadTransfer.PartnerContracts.DiallerServiceReference.DiallerClient client = new LeadTransfer.PartnerContracts.DiallerServiceReference.DiallerClient("wsHttpBinding"); 

您已在客戶端配置,並祝定義以下端點:

<client> 
     <endpoint address="http://localhost/Service.svc/ws" binding="wsHttpBinding" 
      bindingConfiguration="WSHttpBinding_IDialler" contract="WCFServiceDialler.IDialler" 
      name="WSHttpBinding_IDialler"> 
      <identity> 
       <servicePrincipalName value="host/CIDDTS4FCMG4.cis.ad.capita.co.uk" /> 
      </identity> 
     </endpoint> 
     <endpoint address="http://localhost:56435/Service.svc/ws" binding="wsHttpBinding" 
      bindingConfiguration="WSHttpBinding_IDialler1" contract="DiallerServiceReference.IDialler" 
      name="WSHttpBinding_IDialler1"> 
     </endpoint> 
    </client> 

基本上,你告訴客戶端對象從名爲「wsHttpBinding」的配置中的端點節點加載其配置,但唯一可用的端點名爲「WSHttpBinding_IDialler」和「WSHttpBinding_IDialler1」。

的解決方案是更新你被引導到一個現有的端點配置中創建你的客戶對象的方式,就像這樣:

LeadTransfer.PartnerContracts.DiallerServiceReference.DiallerClient client = new LeadTransfer.PartnerContracts.DiallerServiceReference.DiallerClient("WSHttpBinding_IDialler"); 
相關問題