简体   繁体   中英

Startup application is not able to find the endpoint configuration for client WCF Service

I have a ServiceLibrary Application(Host) - LTService which is the starting point of my application. Its contract accepts three arguments username, password and xmlstring. After authenticating it, I am validating and deserializing xmlstring. Now I have one another ServiceLibrary Application(Host) - WCFServiceDialler in the same solution for moment. It accepts a username, password and the object that I have got from the process of deserializing xml above.

I am making my client to consume the DiallerService in another web application prj - partnercontract where I am adding the service reference and it can find the contract that WCFServiceDialler expose. But when I run the following code:

> 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);

The first statement throws an exception that

Could not find endpoint element with name 'wsHttpBinding' and contract 'DiallerServiceReference.IDialler' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

I am not able to figure out that what it is not able to find the endpoint. My startup applications are both the WCF Service projects above.

Following is the wsdl definition in my client service applciation:

    <?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>Pandeysi@cis.ad.capita.co.uk</Upn>
        </Identity>
      </wsa10:EndpointReference>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Configuration for first LTService Application:

<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" />

Configuration for WCFServiceDialler application:

    <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>

Configuration in my project that consumes 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>

In your service client, you are creating an instance of your client object and passing it the name of an endpoint that should exist in your configuration file:

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

You have defined the following endpoints in your client configuration fille:

    <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>  

Basically, you're telling your client object to load its configuration from an endpoint node in the config with a name of "wsHttpBinding", but the only endpoints available are named "WSHttpBinding_IDialler" and "WSHttpBinding_IDialler1".

The solution is to update the way you are creating your client object by directing to an existing endpoint configuration, like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM