0

アプリケーションの開始点である ServiceLibrary Application(Host) - LTService があります。そのコントラクトは、username、password、および xmlstring の 3 つの引数を受け入れます。認証後、xmlstring の検証とデシリアライズを行っています。今、私は別の ServiceLibrary Application(Host) - WCFServiceDialler を同じソリューションに今のところ持っています。上記の xml を逆シリアル化するプロセスから取得したユーザー名、パスワード、およびオブジェクトを受け入れます。

サービス参照を追加している別の Web アプリケーション prj - partnercontract で DiallerService を使用するようにクライアントを作成しており、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' のエンドポイント要素が見つかりませんでした。これは、アプリケーションの構成ファイルが見つからなかったか、この名前に一致するエンドポイント要素が client 要素に見つからなかったためである可能性があります。

エンドポイントを見つけることができないことを理解できません。私のスタートアップ アプリケーションは、上記の WCF サービス プロジェクトの両方です。

以下は、クライアント サービス アプリケーションの 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>Pandeysi@cis.ad.capita.co.uk</Upn>
        </Identity>
      </wsa10:EndpointReference>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

最初の LTService アプリケーションの構成:

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

1 に答える 1

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");
于 2012-08-23T15:59:01.747 に答える