サーバーアプリケーションを開発しています。これは、サーバー マシンで実行される Windows サービスです。サーバー サービスとやり取りするために、WCF サービスを公開しました。他のクライアントは、WCF サービスを使用してサーバーと対話できます。しかし、ユーザーは Windows ベースのシステムしか開発できないため、SOAP サービスも公開することにしました。私は同じの開発の途中です。SOAP サービスは IIS で実行され、WCF サービスと対話しますが、ユーザーは SOAP についてのみ知っているのではなく、WCF サービスについて認識していません。WCF サービスは、ユーザー定義/複雑なデータ型を使用します。SOAP プロジェクトで (サーバーと対話するために) WCF サービスを使用すると、(WCF が使用している) ユーザー定義型にアクセスできます。メソッドを公開して結果にアクセスしようとしましたが、「NetDispatcheFaultException」がスローされました。いくつかのユーザー定義タイプがありますが、問題を引き起こしているタイプは次のとおりです。
public class ServerConfig
{
private List<License> _licenseConfiguration;
public ServerConfig()
{
_licenseConfiguration = new List<License>();
}
[XmlArray("licenseconfiguration", IsNullable = true)]
[XmlArrayItem("license", typeof(License))]
public List<License> LicenseConfiguration { get { return _licenseConfiguration; } set { _licenseConfiguration = value; } }
public string[] AcquiredLicenses
{
get
{
int index = 0;
string[] licenses = new string[LicenseConfiguration.Count];
foreach (License lic in LicenseConfiguration)
{
licenses[index] = Utils.GetUserFriendlyNameFor(lic.LicenseName);
index++;
}
return licenses;
}
}
}
public class License
{
[XmlAttribute("licensename")]
public LicenseTypes LicenseName { get; set; }
[XmlAttribute("licensecount")]
public int LicenseCount { get; set; }
public License()
{
this.LicenseName = LicenseTypes.None;
this.LicenseCount = 0;
}
public License(LicenseTypes licenseName)
{
this.LicenseName = licenseName;
this.LicenseCount = 0;
}
public FbFLicense(LicenseTypes licenseName, int count)
{
this.LicenseName = licenseName;
this.LicenseCount = count;
}
}
SOAP サービスが実行されると、次のメソッドが呼び出され、次に WCF メソッドが呼び出されます。
[WebMethod]
public ServerConfig GetServerConfiguration()
{
return base.ServerConfiguration();//.ServerConfiguration();
}
このメソッドを呼び出すと、WCF 側ではすべてがスムーズに実行されますが、SOAP 側では次の例外がスローされます。
なぜそれが起こっているのですか?これを修正する方法をいくつか提案してください。どちらかを削除すると、この例外は消えます
public string[] AcquiredLicenses
プロパティを ServerConfig クラスから取得するか、戻り値の型を「string[]」から「List(string)」に変更します。何か案が?