2017-01-12 15 views
1

私はGP webserviceに接続してC#アプリケーションから受注を作成しようとしています。しかし、接続しようとすると、以下のように例外がスローされます。以下はGP Webサービスに接続すると例外が発生する

The application encountered an unhandled system exception. Contact your system administrator for details. 

私のapp.configファイル

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="GPWebService" closeTimeout="00:01:00" 
     openTimeout="00:01:00" receiveTimeout="00:10:00" 
     sendTimeout="00:01:00" bypassProxyOnLocal="false" 
     transactionFlow="false" hostNameComparisonMode="StrongWildcard" 
     maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" 
     messageEncoding="Text" textEncoding="utf-8" 
     useDefaultWebProxy="true" allowCookies="false"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" 
      maxArrayLength="16384" maxBytesPerRead="4096" 
      maxNameTableCharCount="2147483647" /> 
      <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" 
      establishSecurityContext="true" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="http://WSGP:48620/Dynamics/GPService/GPService" 
     binding="wsHttpBinding" bindingConfiguration="GPWebService" 
     contract="GPWebService.DynamicsGP" name="GPWebService"> 
     <identity> 
      <userPrincipalName value="WSGP\Administrator" /> 
     </identity> 
     </endpoint> 
    </client> 
    </system.serviceModel> 
</configuration> 

C#のコードは、サービス

CompanyKey companyKey; 
      Context context; 
      SalesOrder salesOrder; 
      SalesDocumentTypeKey salesOrderType; 
      CustomerKey customerKey; 
      BatchKey batchKey; 
      SalesOrderLine salesOrderLine; 
      ItemKey orderedItem; 
      Quantity orderedAmount; 
      Policy salesOrderCreatePolicy; 
      // Create an instance of the service 
      DynamicsGPClient wsDynamicsGP = new DynamicsGPClient(); 
      // Create a context with which to call the service 
      wsDynamicsGP.ClientCredentials.Windows.ClientCredential.UserName = "admin"; 
      wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Password = "pass"; 
      wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = "WSGP"; 
      System.ServiceModel.WSHttpBinding binding; 
      binding = new System.ServiceModel.WSHttpBinding(System.ServiceModel.SecurityMode.None); 
      //wsDynamicsGP.ClientCredentials.Windows.ClientCredential.Domain = "wsgp"; 
      context = new Context(); 
      // Specify which company to use (sample company) 
      companyKey = new CompanyKey(); 
      companyKey.Id = (-1); 
      // Set up the context object 
      context.OrganizationKey = (OrganizationKey)companyKey; 
      // Create a sales order object 
      salesOrder = new SalesOrder(); 
      // Create a sales document type key for the sales order 
      salesOrderType = new SalesDocumentTypeKey(); 
      salesOrderType.Type = SalesDocumentType.Order; 
      // Populate the document type key of the sales order object 
      salesOrder.DocumentTypeKey = salesOrderType; 
      // Create a customer key 
      customerKey = new CustomerKey(); 
      customerKey.Id = "121001"; 
      // Set the customer key property of the sales order object 
      salesOrder.CustomerKey = customerKey; 
      // Create a batch key 
      batchKey = new BatchKey(); 
      batchKey.Id = "RMS"; 
      // Set the batch key property of the sales order object 
      salesOrder.BatchKey = batchKey; 
      // Create a sales order line to specify the ordered item 
      salesOrderLine = new SalesOrderLine(); 
      // Create an item key 
      orderedItem = new ItemKey(); 
      orderedItem.Id = "8011172009618"; 
      // Set the item key property of the sales order line object 
      salesOrderLine.ItemKey = orderedItem; 
      // Create a sales order quantity object 
      orderedAmount = new Quantity(); 
      orderedAmount.Value = 4; 
      // Set the quantity of the sales order line object 
      salesOrderLine.Quantity = orderedAmount; 
      // Create an array of sales order lines 
      // Initialize the array with sales order line object 
      SalesOrderLine[] orders = { salesOrderLine }; 
      // Add the sales order line array to the sales order 
      salesOrder.Lines = orders; 
      // Get the create policy for the sales order object 
      salesOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesOrder", context); 
      // Create the sales order 
      wsDynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy); 
      // Close the service 
      if (wsDynamicsGP.State != CommunicationState.Faulted) 
      { 
       wsDynamicsGP.Close(); 
      } 

GPコンフィグファイルを消費するが、私がやっている何

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 
    <section name="cachingConfiguration" type="Microsoft.Dynamics.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Dynamics.EnterpriseLibrary.Caching, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> 
    </configSections> 
    <cachingConfiguration configSource="WSCachingConfiguration.config"/> 
    <appSettings file="WSServiceAppSettings.config"> 
    <add key="SecurityRuntimeAuditQueuing" value="0"/> 
    <add key="SecurityRuntimeAuditingIsActive" value="false"/> 
    </appSettings> 
    <system.serviceModel> 
    <bindings configSource="WSBindings.config"/> 
    <services> 
     <service name="Microsoft.Dynamics.GP.WebServices.Contract.DynamicsGP" behaviorConfiguration="GPWCFStaticMetadataBehavior"> 
     <endpoint address="Mex" name="http" binding="customBinding" bindingConfiguration="CustomBinding" contract="IMetadataExchange"/> 
     <endpoint address="GPService" name="GPWebService" binding="wsHttpBinding" bindingConfiguration="WSHttpBindingTarget" contract="Microsoft.Dynamics.GP.WebServices.Contract.IGPServices"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://WSGP:48620/Dynamics/GPService"/> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="GPWCFStaticMetadataBehavior"> 
      <serviceThrottling maxConcurrentSessions="1024"/> 
      <serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://WSGP:48620/Metadata/WCF/Full/schemas.microsoft.com.dynamics.gp.2010.01.wsdl"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
      <serviceCredentials> 
      <userNameAuthentication cacheLogonTokens="true"/> 
      </serviceCredentials> 
     </behavior> 
     <behavior name="GPDynamicMetadataBehavior"> 
      <serviceThrottling maxConcurrentSessions="1024"/> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <dataContractSerializer maxItemsInObjectGraph="2147483647"/> 
      <serviceCredentials> 
      <userNameAuthentication cacheLogonTokens="true"/> 
      </serviceCredentials> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <client/> 
    </system.serviceModel> 
    <system.diagnostics> 
    <switches> 
     <add name="ApplicationTraceSwitch" value="0"/> 
    </switches> 
    <trace autoflush="true" indentsize="4"> 
     <listeners> 
     <add name="dynamicsListener"/> 
     </listeners> 
    </trace> 
    <sources> 
     <source name="System.ServiceModel" switchValue="" propagateActivity="true"> 
     <!--Values can be:http://msdn.microsoft.com/en-us/library/ms733025.aspx --> 
     <listeners> 
      <add name="wcfListener"/> 
     </listeners> 
     </source> 
     <source name="System.IO.Log"> 
     <listeners> 
      <add name="wcfListener"/> 
     </listeners> 
     </source> 
     <source name="System.Runtime.Serialization"> 
     <listeners> 
      <add name="wcfListener"/> 
     </listeners> 
     </source> 
     <source name="System.IdentityModel"> 
     <listeners> 
      <add name="wcfListener"/> 
     </listeners> 
     </source> 
    </sources> 
    <sharedListeners> 
     <add name="wcfListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Program Files\Microsoft Dynamics\GPWebServices\Logs\Tracing\GPWebServices.svclog"/> 
     <add name="dynamicsListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\Program Files\Microsoft Dynamics\GPWebServices\Logs\Tracing\GPWebServices.log"/> 
    </sharedListeners> 
    </system.diagnostics> 
</configuration> 

以下でありますここで間違っている?私は設定ファイルに何かがないのですか?

私は、Webサービス開発の初心者です。

答えて

1

私は間違った会社IDを渡していたので、これは問題でした。私はDynamicWebserviceExceptionConsoleから例外の詳細を得ました。私が適切な会社IDを渡そうとしたとき、これは機能しています。

関連する問題