2016-03-20 44 views
0

您好我对Spring一般来说还是比较新的。我一直在使用WebServiceExporter来公开我的WebServices。然而,当我试图另一个WebService的添加到我的web.xml我得到以下错误:无法公开多个服务 - Spring WebServiceExporter

[ArgumentException: Duplicate type name within an assembly.] 
System.Reflection.Emit.ModuleBuilder.CheckTypeNameConflict(String strTypeName, Type enclosingType) +14200621 
System.Reflection.Emit.AssemblyBuilderData.CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) +91 
System.Reflection.Emit.TypeBuilder.Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, Int32 iTypeSize, TypeBuilder enclosingType) +161 
System.Reflection.Emit.ModuleBuilder.DefineTypeNoLock(String name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packingSize, Int32 typesize) +103 
System.Reflection.Emit.ModuleBuilder.DefineType(String name, TypeAttributes attr, Type parent) +289 
Spring.Proxy.DynamicProxyManager.CreateTypeBuilder(String typeName, Type baseType) +145 

[ArgumentException: Proxy already registered for "UserWebService" as Type "UserWebService".] 
Spring.Proxy.DynamicProxyManager.CreateTypeBuilder(String typeName, Type baseType) +353 
Spring.Proxy.CompositionProxyTypeBuilder.BuildProxyType() +149 
Spring.Web.Services.WebServiceExporter.GenerateProxy() +333 
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InvokeInitMethods(Object target, String name, IConfigurableObjectDefinition definition) +269 
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +660 
Spring.Objects.Factory.Support.WebObjectFactory.ConfigureObject(String name, RootObjectDefinition definition, IObjectWrapper wrapper) +135 
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) +933 

[ObjectCreationException: Error creating object with name 'UserWebService' defined in 'file [C:\CODE\Kupla\Kupla\Web.xml] line 13' : Initialization of object failed : Proxy already registered for "UserWebService" as Type "UserWebService".] 
Spring.Objects.Factory.Support.AbstractAutowireCapableObjectFactory.InstantiateObject(String name, RootObjectDefinition definition, Object[] arguments, Boolean allowEagerCaching, Boolean suppressConfigure) +1419 
Spring.Objects.Factory.Support.AbstractObjectFactory.CreateAndCacheSingletonInstance(String objectName, RootObjectDefinition objectDefinition, Object[] arguments) +389 
Spring.Objects.Factory.Support.AbstractObjectFactory.GetObjectInternal(String name, Type requiredType, Object[] arguments, Boolean suppressConfigure) +2103 
Spring.Objects.Factory.Support.DefaultListableObjectFactory.PreInstantiateSingletons() +875 
Spring.Context.Support.AbstractApplicationContext.Refresh() +1225 
Spring.Context.Support.WebApplicationContext..ctor(WebApplicationContextArgs args) +179 
_dynamic_Spring.Context.Support.WebApplicationContext..ctor(Object[]) +252 
Spring.Context.Support.RootContextInstantiator.InvokeContextConstructor(ConstructorInfo ctor) +168 
Spring.Context.Support.ContextHandler.InstantiateContext(IApplicationContext parentContext, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) +192 
Spring.Context.Support.WebContextHandler.InstantiateContext(IApplicationContext parent, Object configContext, String contextName, Type contextType, Boolean caseSensitive, String[] resources) +413 
Spring.Context.Support.ContextHandler.Create(Object parent, Object configContext, XmlNode section) +520 

[ConfigurationErrorsException: Error creating context 'spring.root': Duplicate type name within an assembly.] 
System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) +347 
System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) +2277 
System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) +1849 
System.Configuration.BaseConfigurationRecord.GetSection(String configKey) +69 
Spring.Util.ConfigurationUtils.GetSection(String sectionName) +270 
Spring.Context.Support.WebApplicationContext.GetContextInternal(String virtualPath) +1663 
Spring.Context.Support.WebSupportModule.Init(HttpApplication app) +665 
System.Web.HttpApplication.InitModulesCommon() +192 
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1678 
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +390 
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +194 
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +293 

有没有其他人经历过这种同春,我真的很努力,看看什么是错的。我的web.xml包含:

<?xml version="1.0" encoding="utf-8" ?> 
<objects xmlns="http://www.springframework.net"> 

<object type="default.aspx"> 
<property name="SessionObjectHolder" ref="SessionObjectHolder"/> 
</object> 

<object type="home.aspx"> 
<property name="UserBLL" ref="UserBLL"/> 
<property name="SessionObjectHolder" ref="SessionObjectHolder"/> 
</object> 

<object id="UserWebService" type="Spring.Web.Services.WebServiceExporter, Spring.Web"> 
<property name="TargetName" value="UserWebServiceDTO"/> 
<property name="Namespace" value="http://test.co.uk"/> 
<property name="Description" value="This is User Web Service"/> 
<property name="TypeAttributes"> 
    <list> 
    <object type="System.Web.Script.Services.ScriptServiceAttribute, System.Web.Extensions"/> 
    </list> 
</property> 
</object> 

<object id="UserWebServiceDTO" type="Kupla.ServiceLayer.UserWebService, Kupla.ServiceLayer"> 
<property name="UserBLL" ref="UserBLL" /> 
</object> 

<object id="SessionObjectHolderWebService" type="Spring.Web.Services.WebServiceExporter, Spring.Web"> 
<property name="TargetName" value="SessionObjectHolderWebServiceDTO"/> 
<property name="Namespace" value="http://test.co.uk"/> 
<property name="Description" value="This is the session object holder web service"/> 
<property name="TypeAttributes"> 
    <list> 
    <object type="System.Web.Script.Services.ScriptServiceAttribute, System.Web.Extensions"/> 
    </list> 
</property> 
</object> 

<object id="SessionObjectHolderWebServiceDTO" type="Kupla.ServiceLayer.SessionObjectHolderWebService, Kupla.ServiceLayer"> 
<property name="UserBLL" ref="UserBLL" /> 
</object> 
</objects> 

很多很多很多预先感谢。

回答

1

您的asmxsvc文件是否存在?在Spring创建服务时应该删除它们,因为一个实例是由Spring创建的,其次是由IIS/.NET创建的。

编辑

我还没有发现这个较早,但WebServiceExporter寄存器类型对象的名称 - UserWebService和你的情况SessionObjectHolderWebService。但是这些类型已经存在(由您自己创建),您可以使用DTO后缀调用这些对象。尝试将后缀Exporter添加到由WebServiceExporter创建的对象。

在配置文件中交换服务时出现不同错误的原因是因为Spring只返回第一个错误。在大型项目中可能会非常痛苦。

+0

嗨,扬,我有我的服务层中的两个类。 SessionObjectHolderWebService.cs和UserWebService.cs。这是奇怪的,因为当我改变web.xml中声明Web服务的顺序时。该错误会告诉我SessionObjectHolderWebservice正在被复制。 – user1475128