高度な開発ツールを使用してcrm 4.0からデータを取得する単純なwcfサービスを作成しました。私はlinqを使用して正常にデータを照会しました。クラスはcrmsvcutilを使用して生成されました。しかし、これを以下のようにwcfサービスに変換すると、クラッシュしてしまいます。crm高度な開発ツールとWCFが動作しない
namespace CRMDataRetrieval
{
[ServiceContract]
public interface ICRMData
{
[OperationContract]
string getValue();
}
public class CRMDataService : ICRMData
{
public string getValue()
{
DataContext context = new DataContext("entities"); //entities is name of classes that were generated by crmsvcutil
string name = null;
var query = from n in context.contacts
where n.acctNum == "01218515"
select n.nickname;
foreach (var result in query)
name = result;
return name;
}
WCFサービスホストでは、サービスは停止していますが、Entities.CmsDataServiceも停止していると表示されます。これをクリックすると、追加の情報に、サービス(Entities.CmsDataService)を開始できないことが示されます。このサービスにはエンドポイントが定義されていません。設定ファイルに少なくとも1つのエンドポイントを追加して、もう一度試してください。
私のapp.configのようなものは次のようになります。 WCFでうまく動作するように、自動生成されたクラスの設定ファイルにエンドポイントを追加する方法と場所を教えてください。他の変更を加える必要がありますか? の説明に詳しく記述してください。いつものように、前もってあなたに感謝します。
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="entities" connectionString="Authentication Type=ad; Server=http://****; User ID=*\*******; Password=*******"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings />
<client />
<services>
<service name="CRMDataRetrieval.CRMDataService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:7432/account"/>
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint name="wsHttpBinding_ICRMData" address="ws" binding="wsHttpBinding" contract="CRMDataRetrieval.ICRMData"/>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</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>
<endpointBehaviors>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
を使用するクラスを生成するには
。私は少し 'Entities.CmsDataService'と混同しています。この名前の由来は絶対に不明です。 'CRMDataRetrieval.CRMDataService'のようなものがあります。
私はクラス名DataContextが好きではありません。クラスを生成する必要がありますが、System.Data.Linqのような他の.Net名前空間とのネーミング競合が発生する可能性があります。 – paramosh
Entitiesは、usingステートメントでプロジェクトに含めるcrmsvcutilによって生成されたすべてのクラスを含むフォルダです。 CmsDataServicesは、これらの自動生成クラスの1つです。 DataConextを使わずに進めることをどうお勧めしますか?私はそれを試して喜んでいる。詳細を提供できますか?あなたのご意見ありがとうございます。 –
クイックメモ、自動生成されたクラスのDataContextがある場合、どうやってそれを含めて使用するのですか?これが私に役立つステップ –