Title: com.predic8.soamodel.TypeRefAccessException while creating SOAP request template for WSDL
Tags: java;soap;wsdl;soa;membrane-soa
Question: I have a requirement where i need to create soap xml request template for a particular operation in  WSDL. I am using membrane soa-modeljars to achieve this.
http://www.membrane-soa.org/soa-model-doc/1.4/java-api/create-soap-request-template.htm
It works perfectly fine for simple WSDL which does not references any xsd in it. But it starts failing as soon as i try to load WSDL which has xsd referenced in it.
Below is the error message which I am receiving.
```Exception in thread &quot;main&quot; com.predic8.soamodel.TypeRefAccessException: Could not find the referenced type 'PozSupplierIntDFF' in namespace 'http://xmlns.oracle.com/apps/flex/prc/poz/suppliers/supplierServiceV2/supplierContact/'.
   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
   at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
   at java.lang.reflect.Constructor.newInstance(Unknown Source)
   at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
   at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77)
   at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
   at com.predic8.schema.Schema.findType(Schema.groovy:240)
   at com.predic8.schema.Schema$findType$2.callCurrent(Unknown Source)
   at com.predic8.schema.Schema.getType(Schema.groovy:218)
   at com.predic8.schema.Schema$getType$1.call(Unknown Source)
   at com.predic8.wstool.creator.RequestTemplateCreator.createElement(RequestTemplateCreator.groovy:71)
   at com.predic8.wstool.creator.RequestTemplateCreator$createElement.call(Unknown Source)
   at com.predic8.schema.Element.create(Element.groovy:97)
   at com.predic8.schema.Element$create.call(Unknown Source)
   at com.predic8.schema.creator.AbstractSchemaCreator$_createSequence_closure1.doCall(AbstractSchemaCreator.groovy:61)
   at sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
   at groovy.lang.Closure.call(Closure.java:414)
   at groovy.lang.Closure.call(Closure.java:430)
   at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040)
   at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2025)
   at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2066)
   at org.codehaus.groovy.runtime.dgm$163.invoke(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
   at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
   at com.predic8.schema.creator.AbstractSchemaCreator.createSequence(AbstractSchemaCreator.groovy:60)
   at com.predic8.schema.creator.AbstractSchemaCreator$createSequence.call(Unknown Source)
   at com.predic8.schema.Sequence.create(Sequence.groovy:30)
   at com.predic8.schema.Sequence$create.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:94)
   at com.predic8.wstool.creator.RequestTemplateCreator$_createComplexType_closure2.doCall(RequestTemplateCreator.groovy:103)
   at com.predic8.wstool.creator.RequestTemplateCreator$_createComplexType_closure2.doCall(RequestTemplateCreator.groovy)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
   at groovy.lang.Closure.call(Closure.java:414)
   at groovy.lang.Closure.call(Closure.java:408)
   at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:147)
   at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:67)
   at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:931)
   at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908)
   at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:168)
   at com.predic8.wstool.creator.RequestTemplateCreator.createComplexType(RequestTemplateCreator.groovy:102)
   at com.predic8.wstool.creator.RequestTemplateCreator$createComplexType$0.call(Unknown Source)
   at com.predic8.schema.ComplexType.create(ComplexType.groovy:94)
   at com.predic8.schema.ComplexType$create.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at com.predic8.wstool.creator.RequestTemplateCreator.createElement(RequestTemplateCreator.groovy:73)
   at com.predic8.wstool.creator.RequestTemplateCreator$createElement.call(Unknown Source)
   at com.predic8.schema.Element.create(Element.groovy:97)
   at com.predic8.schema.Element$create.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at com.predic8.schema.creator.AbstractSchemaCreator$_createSequence_closure1.doCall(AbstractSchemaCreator.groovy:61)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
   at groovy.lang.Closure.call(Closure.java:414)
   at groovy.lang.Closure.call(Closure.java:430)
   at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2040)
   at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2025)
   at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2066)
   at org.codehaus.groovy.runtime.dgm$163.invoke(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
   at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
   at com.predic8.schema.creator.AbstractSchemaCreator.createSequence(AbstractSchemaCreator.groovy:60)
   at com.predic8.schema.creator.AbstractSchemaCreator$createSequence.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at com.predic8.schema.Sequence.create(Sequence.groovy:30)
   at com.predic8.schema.Sequence$create.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:94)
   at com.predic8.wstool.creator.RequestTemplateCreator$_createComplexType_closure2.doCall(RequestTemplateCreator.groovy:103)
   at com.predic8.wstool.creator.RequestTemplateCreator$_createComplexType_closure2.doCall(RequestTemplateCreator.groovy)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
   at groovy.lang.Closure.call(Closure.java:414)
   at groovy.lang.Closure.call(Closure.java:408)
   at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:147)
   at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:67)
   at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:931)
   at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908)
   at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:168)
   at com.predic8.wstool.creator.RequestTemplateCreator.createComplexType(RequestTemplateCreator.groovy:102)
   at com.predic8.wstool.creator.RequestTemplateCreator$createComplexType$0.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at com.predic8.schema.ComplexType.create(ComplexType.groovy:94)
   at com.predic8.schema.ComplexType$create.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at com.predic8.wstool.creator.RequestTemplateCreator.createElement(RequestTemplateCreator.groovy:67)
   at com.predic8.wstool.creator.RequestTemplateCreator$createElement.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at com.predic8.schema.Element.create(Element.groovy:97)
   at com.predic8.schema.Element$create.call(Unknown Source)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
   at com.predic8.wstool.creator.SOARequestCreator$_buildBody_closure3.doCall(SOARequestCreator.groovy:98)
   at com.predic8.wstool.creator.SOARequestCreator$_buildBody_closure3.doCall(SOARequestCreator.groovy)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
   at groovy.lang.Closure.call(Closure.java:414)
   at groovy.lang.Closure.call(Closure.java:408)
   at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:147)
   at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:67)
   at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:931)
   at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908)
   at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:168)
   at com.predic8.wstool.creator.SOARequestCreator.buildBody(SOARequestCreator.groovy:83)
   at com.predic8.wstool.creator.SOARequestCreator.this$3$buildBody(SOARequestCreator.groovy)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
   at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
   at com.predic8.wstool.creator.SOARequestCreator$_createRequest_closure2.doCall(SOARequestCreator.groovy:78)
   at com.predic8.wstool.creator.SOARequestCreator$_createRequest_closure2.doCall(SOARequestCreator.groovy)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
   at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
   at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
   at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
   at groovy.lang.Closure.call(Closure.java:414)
   at groovy.lang.Closure.call(Closure.java:408)
   at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:147)
   at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:67)
   at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:931)
   at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:908)
   at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:168)
   at com.predic8.wstool.creator.SOARequestCreator.createRequest(SOARequestCreator.groovy:74)
   at testdhananjay.testclass.main(testclass.java:61)
```



Here is another answer: i had a similiar problem. I called this method.
``` ComplexType complexType = schema.getComplexType(e.getType().getLocalPart());
```
I had the problem that there is no complex Type available. If you have a XSD File you will get two schemas.
```final List<Schema&gt; schemas = definitions.getSchemas(); // Deliver you two schemas
```
If you go through the schemas you will see that your complexType will be in an other schema.
```    for (final Schema schema : schemas) {

        System.out.println(&quot;Complextypes Numer: &quot; + schema.getComplexTypes().size());
        for (final ComplexType c : schema.getComplexTypes()) {
            System.out.println(&quot;Complextypes: &quot; + c.getName());
        }
    }
```
You need the correct schema to get access to this type. I hope that will help you and others.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2021:00:03/09/21', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><soap><wsdl><soa><membrane-soa>', 'Title': 'com.predic8.soamodel.TypeRefAccessException while creating SOAP request template for WSDL', 'ViewCount': 95, 'id': 66545683, 'user_AboutMe': '', 'user_AccountId': 4181784.0, 'user_DisplayName': 'dhananjay sharma', 'user_Reputation': 9.0, 'user_Views': 11.0, 'user_id': 3426601.0}}