3

複数のバックエンド サービス (現在 2 つ) を呼び出すブローカー サービスを構築しています。すべてのサービスのインターフェースは同じです。次のスライドは、英語ではありませんが、展開を示しています

ダイアグラム

インターフェイスは、wsdl.exe を使用して WSDL からコンパイルされました。インターフェイスには明らかにすべての C# 属性が含まれています

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")]
[System.Web.Services.WebServiceBindingAttribute(Name="ServizioSanitario", Namespace="http://innovazione-ict.unina.it/WSDLSanita")]
public interface IServizioSanitario {

    /// <remarks/>
    [System.Web.Services.WebMethodAttribute()]
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://innovazione-ict.unina.it/WSDLSanita/InserisciDocumento", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
    [return: XmlElement("idDocumento", Namespace="http://innovazione-ict.unina.it/WSDLSanita", DataType="ID")]
    string InserisciDocumento([XmlElement(Namespace="http://innovazione-ict.unina.it/WSDLSanita")] Documento documento);

    /// <remarks/>
    [System.Web.Services.WebMethodAttribute()]
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://innovazione-ict.unina.it/WSDLSanita/OttieniListaDocumenti", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
    [return: XmlArray("listaMetadati", Namespace="http://innovazione-ict.unina.it/WSDLSanita")]
    [return: XmlArrayItem("metadatiDocumento", IsNullable=false)]
    MetadatiDocumentoTrovato[] OttieniListaDocumenti([XmlElement(Namespace="http://innovazione-ict.unina.it/WSDLSanita")] string codiceFiscale);

    /// <remarks/>
    [System.Web.Services.WebMethodAttribute()]
    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://innovazione-ict.unina.it/WSDLSanita/RecuperaDocumento", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
    [return: XmlElement("documento", Namespace="http://innovazione-ict.unina.it/WSDLSanita")]
    Documento RecuperaDocumento([XmlElement(Namespace="http://innovazione-ict.unina.it/WSDLSanita", DataType="ID")] string idDocumento);
}

ブローカーは、動的プロキシとスケルトンのインスタンス化を使用して Spring.net 上に構築されています。これは、別のアセンブリに実装された Web サービスを公開する空の webapp で構成されています。

ブローカーには、独自のインターフェースを介して他のサービスへの参照が含まれています。

class Broker : IServizioSanitario
{
        public IServizioSanitario[] ServiziConcreti { private get; set; }
}

ブローカーによって呼び出される各サービスの動的プロキシをインスタンス化したいと考えています。このために、Spring.net 依存性注入フラグメントを使用しました。

    <object id="ServizioSanitarioNetProxy" type="Spring.Web.Services.WebServiceProxyFactory, Spring.Services">
        <property name="ServiceUri" value="http://localhost:2263/ServizioSanitario2.asmx"/>
        <property name="ServiceInterface" value="It.Unina.MasterICT.ServizioSanitarioReference.IServizioSanitario, ServizioSanitarioReference"/>
      </object>

  <object id="BrokerConcrete" type="It.Unina.MasterICT.ServizioSanitario.Broker.Broker, BrokerImpl">
    <property name="ServiziConcreti">
      <list>
        <ref object="ServizioSanitarioDummyProxy"/>
        <ref object="ServizioSanitarioNetProxy"/>
      </list>
    </property>
  </object>

webapp を実行しようとすると、次のエラーが表示されます

System.InvalidOperationException: Element idDocument, belonging to namespace http://innovazione-ict.unina.it/WSDLSanita, imported in two different contexts: PrimitiveMapping, MembersMapping.

[InvalidOperationException: Elemento idDocumento, appartenente allo spazio dei nomi http://innovazione-ict.unina.it/WSDLSanita, importato in due diversi contesti: PrimitiveMapping, MembersMapping.]
   System.Xml.Serialization.XmlSchemaImporter.ImportElementType(XmlSchemaElement element, String identifier, Type desiredMappingType, Type baseType, String ns) +813951
   System.Xml.Serialization.XmlSchemaImporter.ImportElement(XmlSchemaElement element, String identifier, Type desiredMappingType, Type baseType, String ns, Boolean topLevelElement) +284
   System.Xml.Serialization.XmlSchemaImporter.ImportElement(XmlQualifiedName name, Type desiredMappingType, Type baseType) +207
   System.Xml.Serialization.XmlSchemaImporter.ImportMembersMapping(XmlQualifiedName name) +82
   Spring.Web.Services.SoapHttpClientProxyTypeBuilder.GetMembersMapping(String messageName, MessagePartCollection messageParts, SoapBodyBinding soapBodyBinding, SoapBindingStyle soapBindingStyle) +376
   Spring.Web.Services.SoapHttpClientProxyTypeBuilder.MoveToMethod(MethodInfo targetMethod) +1481
   Spring.Web.Services.SoapHttpClientProxyTypeBuilder.ApplyMethodAttributes(MethodBuilder methodBuilder, MethodInfo targetMethod) +37
   Spring.Proxy.AbstractProxyTypeBuilder.ImplementInterface(TypeBuilder typeBuilder, IProxyMethodBuilder proxyMethodBuilder, Type intf, Type targetType, Boolean proxyVirtualMethods) +423
   Spring.Proxy.AbstractProxyTypeBuilder.ImplementInterface(TypeBuilder typeBuilder, IProxyMethodBuilder proxyMethodBuilder, Type intf, Type targetType) +50
   Spring.Web.Services.SoapHttpClientProxyTypeBuilder.BuildProxyType() +367
   Spring.Web.Services.WebServiceProxyFactory.GenerateProxy() +379
   Spring.Web.Services.WebServiceProxyFactory.GetObject() +55
   Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectFromFactoryObject(IFactoryObject factory, String objectName, RootObjectDefinition rod) +84

[ObjectCreationException: Error thrown by a dependency of object 'BrokerConcrete' defined in 'config [C:\Users\DJ Echelon\documents\visual studio 2010\Projects\MasterICT\BrokenSanitario\WebappBroker\web.config#spring/objects] line 1' : FactoryObject threw exception on object creation.
 while resolving 'ServiziConcreti[0]' to 'ServizioSanitarioNetProxy' defined in 'config [C:\Users\DJ Echelon\documents\visual studio 2010\Projects\MasterICT\BrokenSanitario\WebappBroker\web.config#spring/objects] line 1']
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolveReference(IObjectDefinition definition, String name, String argumentName, RuntimeObjectReference reference) +644
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolvePropertyValue(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +672
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolveValueIfNecessary(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +56
   Spring.Objects.Factory.Config.ManagedList.Resolve(String objectName, IObjectDefinition definition, String propertyName, ManagedCollectionElementResolver resolver) +599
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolvePropertyValue(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +1478
   Spring.Objects.Factory.Support.ObjectDefinitionValueResolver.ResolveValueIfNecessary(String name, IObjectDefinition definition, String argumentName, Object argumentValue) +56
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ApplyPropertyValues(String name, RootObjectDefinition definition, IObjectWrapper wrapper, IPropertyValues properties) +299
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.PopulateObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +1218
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +146
   Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) +970
   Spring.Objects.Factory.Support.AbstractObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +228
   Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(String name, Type requiredType, Object[] arguments, Boolean suppressConfigure) +1563
   Spring.Objects.Factory.Support.AbstractObjectFactory.GetObject(String name) +43
   Spring.Objects.Factory.Support.DefaultListableObjectFactory.PreInstantiateSingletons() +720
   Spring.Context.Support.AbstractApplicationContext.Refresh() +1356
   Spring.Context.Support.XmlApplicationContext..ctor(XmlApplicationContextArgs args) +334
   Spring.Context.Support.XmlApplicationContext..ctor(String name, Boolean caseSensitive, String[] configurationLocations) +76
   _dynamic_Spring.Context.Support.XmlApplicationContext..ctor(Object[] ) +238
   Spring.Reflection.Dynamic.SafeConstructor.Invoke(Object[] arguments) +42
   Spring.Context.Support.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) +241
   Spring.Context.Support.ContextInstantiator.InstantiateContext() +190
   Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) +152
   Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) +536

[ConfigurationErrorsException: Error creating context 'spring.root': Elemento idDocumento, appartenente allo spazio dei nomi http://innovazione-ict.unina.it/WSDLSanita, importato in due diversi contesti: PrimitiveMapping, MembersMapping.]
   System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) +199
   System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) +1153
   System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +1468
   System.Configuration.BaseConfigurationRecord.GetSection(String configKey) +41
   System.Web.HttpContext.GetSection(String sectionName) +52
   System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName) +57
   System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) +6
   System.Configuration.ConfigurationManager.GetSection(String sectionName) +78
   Spring.Util.ConfigurationUtils.GetSection(String sectionName) +151
   Spring.Context.Support.WebApplicationContext.GetContextInternal(String virtualPath) +1181
   Spring.Context.Support.WebApplicationContext.GetContext(String virtualPath) +31
   Spring.Web.Services.WebServiceHandlerFactory.System.Web.IHttpHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String path) +130
   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +203
   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +128
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Spring チュートリアルに従って、手動で作成され、wsdl.exe からコンパイルされていないインターフェイスを使用します。http://localhost:2263/ServizioSanitario2.asmxは、別のソリューションから別のプロジェクトがあり、次のように定義された Web サービスを実行しています .exe コンパイル。

私の現在の課題では、実装クラスの互換性を可能にするために、インターフェイス (= 同じインターフェイス) の使用法を明確に示すことが重要です (基本的に、プロバイダーはリモート オブジェクトまたはローカル オブジェクトでいつでも変更できることを示します)。

したがって、基本的に上記の属性なしの新しいインターフェースをハンドキャフトすることなく、このエラーを乗り越えたいと思います。

出来ますか?SOAPメッセージで交換する複雑なデータ型があることを考慮してください。データ オブジェクトには独自の XML シリアライゼーション属性があるため、" clear-of-attributes " インターフェイスを持つことは現実的ではありません。

ありがとうございました。

4

0 に答える 0