Skip to content

Commit 2efa998

Browse files
authored
Merge pull request #28 from virtualansoftware/2.0.1-release
2.0.1 release
2 parents bdfa7c5 + 9d26765 commit 2efa998

File tree

11 files changed

+29887
-185
lines changed

11 files changed

+29887
-185
lines changed

modules/virtualan-plugin/src/main/java/io/virtualan/core/soap/SoapEndpointCodeGenerator.java

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,12 @@ public static Class buildEndpointClass(Map<String, SoapService> soapWsServices)
6565
addParameterAnnotation(cc, method);
6666
addMethodAnnotation(cc, soapService, method);
6767
}
68-
//cc.getClassFile()
69-
// .write(new DataOutputStream(new FileOutputStream("VirtualanEndpoint.class")));
70-
return cc.toClass();
68+
// log.info("##########################");
69+
// cc.getClassFile()
70+
// .write(new DataOutputStream(System.out));
71+
// log.info("##########################");
72+
//
73+
return cc.toClass();
7174
}
7275

7376
private static void addMethodAnnotation(CtClass cc, SoapService soapService, CtMethod method) {
@@ -157,22 +160,28 @@ private static ClassPathScanningCandidateComponentProvider createComponentScanne
157160
return provider;
158161
}
159162

160-
protected List<Class> findMyTypes(String basePackage) throws IOException, ClassNotFoundException {
161-
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
162-
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(
163-
resourcePatternResolver);
163+
protected List<Class> findMyTypes(String basePackage) {
164164
List<Class> candidates = new ArrayList<Class>();
165-
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
166-
resolveBasePackage(basePackage) + "/" + "**/*.class";
167-
Resource[] resources = resourcePatternResolver.getResources(packageSearchPath);
168-
for (Resource resource : resources) {
169-
if (resource.isReadable()) {
170-
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
171-
if (isCandidate(metadataReader)) {
172-
candidates.add(Class.forName(metadataReader.getClassMetadata().getClassName()));
165+
try {
166+
ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
167+
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(
168+
resourcePatternResolver);
169+
String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX +
170+
resolveBasePackage(basePackage) + "/" + "**/*.class";
171+
Resource[] resources = new Resource[0];
172+
resources = resourcePatternResolver.getResources(packageSearchPath);
173+
for (Resource resource : resources) {
174+
if (resource.isReadable()) {
175+
MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(resource);
176+
if (isCandidate(metadataReader)) {
177+
candidates.add(Class.forName(metadataReader.getClassMetadata().getClassName()));
178+
}
173179
}
174180
}
181+
} catch (IOException | ClassNotFoundException e) {
182+
log.warn("Unable to load the package : " + basePackage);
175183
}
184+
176185
return candidates;
177186
}
178187

modules/virtualan-plugin/src/main/java/io/virtualan/core/soap/WSEndpointConfiguration.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,16 @@ public void setBeanFactory(BeanFactory beanFactory) {
5353
public void loadSoapWSservice() throws Exception {
5454
DefaultListableBeanFactory beanRegistry = (DefaultListableBeanFactory) beanFactory;
5555

56-
//TODO MUST
57-
List<Class> portTypeList = soapEndpointCodeGenerator.findMyTypes(soapPackage);
58-
for(Class clazz : portTypeList) {
59-
Method[] methods = clazz.getDeclaredMethods();
60-
Arrays.stream(methods).forEach( method -> {
61-
loadParameters(method);
62-
});
56+
Arrays.stream(soapPackage.split(";")).forEach( packageName -> {
57+
List<Class> portTypeList = soapEndpointCodeGenerator.findMyTypes(packageName);
58+
for(Class clazz : portTypeList) {
59+
Method[] methods = clazz.getDeclaredMethods();
60+
Arrays.stream(methods).forEach( method -> {
61+
loadParameters(method);
62+
});
63+
}
6364
}
65+
);
6466

6567
GenericBeanDefinition virtualanSOAPWS = new GenericBeanDefinition();
6668
virtualanSOAPWS.setBeanClass(soapEndpointCodeGenerator.buildEndpointClass(wsServiceMockList));

samples/virtualan-wsdl-soap/pom.xml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
<wsdlOption>
3737
<wsdl>${basedir}/src/main/resources/wsdl/helloworld.wsdl</wsdl>
3838
<extraargs>
39-
<extraarg>-verbose</extraarg>
4039
<extraarg>-xjc-Xequals</extraarg>
4140
<extraarg>-xjc-XhashCode</extraarg>
4241
<extraarg>-xjc-XtoString</extraarg>
@@ -45,7 +44,39 @@
4544
<bindingFile>${project.basedir}/src/main/resources/xjb/bindings.xjb</bindingFile>
4645
</bindingFiles>
4746
</wsdlOption>
48-
</wsdlOptions>
47+
<wsdlOption>
48+
<autoNameResolution>true</autoNameResolution>
49+
<wsdl>${basedir}/src/main/resources/wsdl/sforce-49/partner.wsdl</wsdl>
50+
<extraargs>
51+
<extraarg>-xjc-Xequals</extraarg>
52+
<extraarg>-xjc-XhashCode</extraarg>
53+
<extraarg>-xjc-XtoString</extraarg>
54+
<extraarg>-p</extraarg>
55+
<extraarg>com.sforce.partner</extraarg>
56+
</extraargs>
57+
<bindingFiles>
58+
<bindingFile>${project.basedir}/src/main/resources/xjb/bindings.xjb</bindingFile>
59+
</bindingFiles>
60+
</wsdlOption>
61+
<wsdlOption>
62+
<autoNameResolution>true</autoNameResolution>
63+
<wsdl>${basedir}/src/main/resources/wsdl/sforce-49/apex.wsdl</wsdl>
64+
</wsdlOption>
65+
<wsdlOption>
66+
<autoNameResolution>true</autoNameResolution>
67+
<wsdl>${basedir}/src/main/resources/wsdl/sforce-49/apex.wsdl</wsdl>
68+
<extraargs>
69+
<extraarg>-xjc-Xequals</extraarg>
70+
<extraarg>-xjc-XhashCode</extraarg>
71+
<extraarg>-xjc-XtoString</extraarg>
72+
<extraarg>-p</extraarg>
73+
<extraarg>com.sforce.apex</extraarg>
74+
</extraargs>
75+
<bindingFiles>
76+
<bindingFile>${project.basedir}/src/main/resources/xjb/bindings.xjb</bindingFile>
77+
</bindingFiles>
78+
</wsdlOption>
79+
</wsdlOptions>
4980

5081
</configuration>
5182

samples/virtualan-wsdl-soap/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ virtualan.datasource.username=sa
55
virtualan.datasource.password=
66
virtualan.application.name=The Service Virtualization Product
77
virtualan.data.load=initial-load.json
8-
virtualan.soap.package=io.virtualan
8+
virtualan.soap.package=com.sforce;com.virtualan;io.virtualan

samples/virtualan-wsdl-soap/src/main/resources/initial-load.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,16 @@
88
"resource": "http://virtualan.io/types/helloworld",
99
"contentType": "XML",
1010
"requestType" : "SOAP"
11-
}
11+
},
12+
{
13+
"operationId": "person",
14+
"url": "http://virtualan.io/types/helloworld",
15+
"method": "person",
16+
"type": "Response",
17+
"input": "<hel:person xmlns:hel=\"http://virtualan.io/types/helloworld\"> \t<hel:firstName>Elan</hel:firstName> \t<hel:lastName>Thangamani</hel:lastName> </hel:person>",
18+
"output": "<ns2:greeting xmlns:ns2=\"http://virtualan.io/types/helloworld\"> <ns2:greeting>Welcome World SV!!!</ns2:greeting></ns2:greeting>",
19+
"resource": "http://virtualan.io/types/helloworld",
20+
"contentType": "XML",
21+
"requestType" : "SOAP"
22+
}
1223
]

0 commit comments

Comments
 (0)