2

これを公開するWebサービスがあります$metadata

<?xml version="1.0" encoding="UTF-8" standalone="true"?>
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">     > <edmx:DataServices m:DataServiceVersion="1.0"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

<Schema xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://schemas.microsoft.com/ado/2007/05/edm"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
Namespace="NAV"> 
<EntityType Name="PAsset"> 
<Key> <PropertyRef Name="No"/> </Key>  <Property Name="No" Nullable="false" Type="Edm.String"/>  <Property Name="Description"
Nullable="true" Type="Edm.String"/>  <Property Name="Inactive"
Nullable="false" Type="Edm.Boolean"/>  <Property Name="Insured"
Nullable="false" Type="Edm.Boolean"/> </EntityType> 

<EntityType Name="PAssetsDepreciationBook">

<EntityType Name="PBankAPostGrp">
<EntityType Name="PCompany">
<EntityType Name="PCustomer">

$metadataC#アプリケーションでこの情報を取得することは可能ですか?

サービスへの参照が機能しているアプリケーションと、使用しているコードがあります。

uriString = String.Format( "PAssetsDepreciationBook?$ filter = FA_No eq'{0}'"、cliente);

contex = new ServiceReference1.NAV(new Uri(serviceEndPoint)); contex.Credentials = CredentialCache.DefaultCredentials;

var Customers = contex.Execute(new Uri(uriString、UriKind.Relative));

foreach(顧客のvar c){結果=結果+ c.Acquisition_Cost; }結果を返します。

これは正常に機能しますが、取得することはでき$metadataません。

4

3 に答える 3

1

ありがとう、それはうまくいきます。

ちょうどこのような:

// Create a request for the URL. 
WebRequest request = WebRequest.Create("http://localhost:7048/DynamicsNAV70/OData/$metadata");

//set the credentials.
request.Credentials = CredentialCache.DefaultCredentials;

// Get the response.
WebResponse response = request.GetResponse();

// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();

// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);

// Read the content.
string responseFromServer = reader.ReadToEnd();

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(new StringReader(responseFromServer));

// Clean up the streams and the response.
reader.Close();
response.Close();

この後、xml ファイルのようにデータを解析するだけです。

于 2012-07-04T13:29:22.247 に答える
1

HttpWebRequestたとえば、メタデータをプレーンな XML としてリクエストできます。解析する必要がある場合は、( )EdmLibMicrosoft.Data.Edm.dll使用できNuGetます。これらを読み取るように特別に設計されています (それでも EDM オブジェクト モデルを返しますが、ラッパーとバージョン管理を処理するだけです)。ODataLibMicrosoft.Data.OData.dllNugetODataMessageReaderReadMetadataDocumentEDMX

于 2012-07-03T15:44:21.047 に答える