4

開発したWCFサービスを呼び出そうとすると、「メソッドまたは操作が実装されていません」というエラーメッセージが表示されます。

私が直面しているシナリオについて説明しましょう。詳細やコードなどを説明します。

Windows 8 / VisualStudio2012マシンの.NETFramework4.0でWCfサービスを開発しています。WCFサービスには、.NET Compact Framework 2.0で開発されたモバイルアプリケーション(開発環境:Windows XP Service Pack 3、Visual Studio 2008、Windows Mobile 6.1 Professional Emulatorを実行する仮想マシン)からアクセスします。

WCFサービスは、SAP .NET Conector(SAPnCO)バージョン3.0を使用しています。

VS統合IISまたはIIS8を使用してサービスを実行すると、すべてが正常に機能します。サービスをテストし、テストコンソールアプリケーションからアクセスし、WindowsMo​​bileエミュレーターからアクセスできます。

ただし、最終ユーザーでいくつかの予備テストを開始しようとしていて、WCFアプリケーションを展開するための適切なサーバーがまだなかったため、WindowsXPとIISExpress 7.5を使用して緊急サーバーを作成する必要がありました(できませんでした) IIS 5.1で動作させるため)。

IIS Expressがローカルアクセス専用であることは知っていますが、このチュートリアルに従ってLANに対してtiを開きます:チュートリアル

そうすることで、ブラウザーを介してサービス署名にアクセスし、WSDLファイルを表示できます。

サービスにアクセスしようとするたびに、「メソッドまたは操作が実装されていません」というエラーメッセージが表示されます。私は過去4時間、インターネット上で同様の問題を探していましたが、成功しませんでした。

これが私がこれまでに何とかしたことです:

  • IIS Express 7.5でデフォルトのWCFサンプルサービスをホストし、サービスをリモートで使用します。
  • 元のサービスの範囲を最小限に減らします。それでも同じエラーが発生します。

だから、私はまだこれを引き起こしている可能性があるものやそれを解決する方法を知りません。よろしくお願いします!

これが私のコードです:

WEB.CONFIG

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="SAP.Middleware.Connector">
      <sectionGroup name="ClientSettings">
        <section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco"/>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <SAP.Middleware.Connector>
    <ClientSettings>
      <DestinationConfiguration>
        <destinations>
          <add NAME="QA" USER="XX" PASSWD="XX" CLIENT="XX" LANG="XX" ASHOST="XX" SYSNR="XX" MAX_POOL_SIZE="XX" IDLE_TIMEOUT="XX"/>
        </destinations>
      </DestinationConfiguration>
    </ClientSettings>
  </SAP.Middleware.Connector>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <appSettings/>
  <system.web>
    <compilation targetFramework="4.0" debug="true"/>
    <httpRuntime/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
      </system.webServer>
    </configuration>

サービス

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

using SAP.Middleware.Connector;

namespace WCFCriarOT
{

    public class Service1 : IService1
    {

        public string CriarOT(int areaSelecionada, int nlenr, string codMaterial, int qtdMAterial)
        {
            try
            {


                string vltyp = "", vlpla = "";

                switch (areaSelecionada)
                {
                    case 1:
                        vltyp = "902";
                        vlpla = "GR-ZONE";
                        break;
                    case 3:
                        vltyp = "901";
                        vlpla = "GFI-ZONE";
                        break;
                    case 4:
                        vltyp = "904";
                        vlpla = "DEVOLUCAO";
                        break;
                    default:
                        break;
                }

                RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("QA");
                RfcRepository SapRfcRepository = SapRfcDestination.Repository;
                IRfcFunction FCriarOT = SapRfcRepository.CreateFunction("ZWM001");

                FCriarOT.SetValue("I_LGNUM", "WM1");
                FCriarOT.SetValue("I_BWLVS", "999");
                FCriarOT.SetValue("I_MATNR", codMaterial);
                FCriarOT.SetValue("I_WERKS", "120");
                FCriarOT.SetValue("I_LGORT", "0001");
                FCriarOT.SetValue("I_ANFME", qtdMAterial);
                FCriarOT.SetValue("I_SQUIT", "");
                FCriarOT.SetValue("I_VLTYP", vltyp);
                FCriarOT.SetValue("I_VLPLA", vlpla);
                FCriarOT.SetValue("I_VLENR", "");
                FCriarOT.SetValue("I_NLTYP", "");
                FCriarOT.SetValue("I_NLPLA", "");
                FCriarOT.SetValue("I_NLENR", nlenr.ToString().PadLeft(20, '0'));
                FCriarOT.SetValue("I_BNAME", "PAGOTR"); // receber os dados do login posteriormente

                FCriarOT.Invoke(SapRfcDestination);

                if (Convert.ToInt32(FCriarOT.GetValue("E_RETURN")) == 1)
                {
                    IRfcTable RfcReturn = FCriarOT.GetTable("T_MSG");
                    RfcReturn.CurrentIndex = 0;



                    return "1";
                }
                else
                {


                    return "0";
                }
            }
            catch (Exception ex)
            {
                throw new NotImplementedException();

            }
        }
    } 

サービス署名

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WCFCriarOT
{

    [ServiceContract]
    public interface IService1
    {
        // Contrato para a operação "Criar OT"
        [OperationContract]
        string CriarOT(int areaSelecionada, int nlenr, string codMaterial, int qtdMAterial);

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
    }
    }

例外

System.ServiceModel.FaultException`1 was unhandled
  HResult=-2146233087
  Message=O método ou a operação não está implementada.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at testeDoTeste1.ServiceReference1.IService1.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial)
       at testeDoTeste1.ServiceReference1.Service1Client.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Service References\ServiceReference1\Reference.cs:line 119
       at testeDoTeste1.Program.Main(String[] args) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Program.cs:line 16
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

必要な情報をすべて提供できなかった場合は、お知らせください。できる限りの情報を提供します。私は本当にあなたのすべての助けを必要とし、それを先取りします!たくさんTks!

--------------

更新1

WEB.CONFIGファイルは、WCFサービスをIIS Expressで機能させるために編集される唯一のサービスであるため、これが(実際には)問題の原因になる可能性があると思います。私は元のWEB.CONFIGファイルを投稿していますが、これが誰かが問題を見つけるのに役立つことを期待して編集することはありません!

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="SAP.Middleware.Connector">
      <sectionGroup name="ClientSettings">
        <section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco"/>
      </sectionGroup>
    </sectionGroup>
  </configSections>
  <SAP.Middleware.Connector>
    <ClientSettings>
      <DestinationConfiguration>
        <destinations>
          <add NAME="QA" USER="XX" PASSWD="XX" CLIENT="XX" LANG="XX" ASHOST="XX" SYSNR="XX" MAX_POOL_SIZE="XX" IDLE_TIMEOUT="XX"/>
        </destinations>
      </DestinationConfiguration>
    </ClientSettings>
  </SAP.Middleware.Connector>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <appSettings/>
  <system.web>
    <compilation targetFramework="4.0" debug="true"/>
    <httpRuntime/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
      <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>

--------------

更新2

新しいエラーが見つかりましたが、それでもあいまいです:「{"宛先QAを取得できません-宛先構成が登録されていません"}」。この宛先は開発では正常に機能しますが、IISExpressで機能しないのはなぜですか。

とにかく、これが完全な例外です:

System.ServiceModel.FaultException`1 was unhandled
  HResult=-2146233087
  Message=Cannot get destination QA -- no destination configuration registered
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at testeDoTeste1.ServiceReference1.IService1.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial)
       at testeDoTeste1.ServiceReference1.Service1Client.CriarOT(Int32 areaSelecionada, Int32 nlenr, String codMaterial, Int32 qtdMAterial) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Service References\ServiceReference1\Reference.cs:line 119
       at testeDoTeste1.Program.Main(String[] args) in c:\Users\Documents\Visual Studio 2012\Projects\testeDoTeste1\testeDoTeste1\Program.cs:line 16
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

--------------

4

2 に答える 2

3

この例外は、sapncoアセンブリがロードされていない場合に発生することがわかりました。参照されるSAPアセンブリをローカルコピーに設定してみてください:True。

これは理想的な解決策ではありませんが、私にとってはうまくいきました。

于 2013-12-11T09:01:31.423 に答える
0

configSectionsのセクションをapp.configの先頭に移動することで解決しました。たぶん、「configSections」は構成の最初の子セクションでなければなりません。

こちらもご覧ください: パラメータ'sectionGroupName'が無効です

于 2021-08-04T12:35:33.740 に答える