Skip to content

Commit 95abc47

Browse files
committed
Minor updates
1 parent 458bff7 commit 95abc47

File tree

4 files changed

+203
-159
lines changed

4 files changed

+203
-159
lines changed

simple-tests/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ Then to run a test against a specific Camel version:
1717
Here's a (non-exhaustive!) list of the scenarios included in this part of the repo, primarily for the benefit of people searching the web. Scenarios are usually where I do little POCs to prove something, or not.
1818

1919
- **CxfCustomNamespacePrefixTest** - This shows how to customise CXF to use specific prefixes when referring to namespaces. This was born out of a requirement where a legacy web service client was not able to understand unqualified values in XML attributes. CXF will try to set a default namespace where it can. If legacy clients don't fully understand this, then CXF behaviour can be customised by creating a CXF endpoint manually and setting namespaces. This scenario shows how.
20+
21+
## Other things
22+
23+
To generate client classes from WSDL:
24+
25+
mvn org.apache.cxf:cxf-codegen-plugin:wsdl2java
Lines changed: 160 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,175 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
3-
xmlns:tns="http://www.cleverbuilder.com/BookService/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
4-
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="BookService"
3+
xmlns:tns="http://www.cleverbuilder.com/BookService/"
4+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
5+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
6+
name="BookService"
57
targetNamespace="http://www.cleverbuilder.com/BookService/">
6-
<wsdl:documentation>Definition for a web service called BookService,
7-
which can be used to add or retrieve books from a collection.
8-
</wsdl:documentation>
8+
<wsdl:documentation>Definition for a web service called BookService,
9+
which can be used to add or retrieve books from a collection.
10+
</wsdl:documentation>
911

10-
<!--
11-
The `types` element defines the data types (XML elements)
12-
that are used by the web service.
13-
-->
14-
<wsdl:types>
15-
<xsd:schema targetNamespace="http://www.cleverbuilder.com/BookService/">
16-
<xsd:element name="Book">
17-
<xsd:complexType>
18-
<xsd:sequence>
19-
<xsd:element name="ID" type="xsd:string" minOccurs="0"/>
20-
<xsd:element name="Title" type="xsd:string"/>
21-
<xsd:element name="Author" type="xsd:string"/>
22-
</xsd:sequence>
23-
</xsd:complexType>
24-
</xsd:element>
25-
<xsd:element name="Books">
26-
<xsd:complexType>
27-
<xsd:sequence>
28-
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="unbounded"/>
29-
</xsd:sequence>
30-
</xsd:complexType>
31-
</xsd:element>
12+
<!--
13+
The `types` element defines the data types (XML elements)
14+
that are used by the web service.
15+
-->
16+
<wsdl:types>
17+
<xsd:schema targetNamespace="http://www.cleverbuilder.com/BookService/">
18+
<xsd:element name="Book">
19+
<xsd:complexType>
20+
<xsd:sequence>
21+
<xsd:element name="ID" type="xsd:string" minOccurs="0"/>
22+
<xsd:element name="Title" type="xsd:string"/>
23+
<xsd:element name="Author" type="xsd:string"/>
24+
</xsd:sequence>
25+
</xsd:complexType>
26+
</xsd:element>
27+
<xsd:element name="Books">
28+
<xsd:complexType>
29+
<xsd:sequence>
30+
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="unbounded"/>
31+
</xsd:sequence>
32+
</xsd:complexType>
33+
</xsd:element>
3234

33-
<xsd:element name="GetBook">
34-
<xsd:complexType>
35-
<xsd:sequence>
36-
<xsd:element name="ID" type="xsd:string" />
37-
</xsd:sequence>
38-
</xsd:complexType>
39-
</xsd:element>
40-
<xsd:element name="GetBookResponse">
41-
<xsd:complexType>
42-
<xsd:sequence>
43-
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="1"/>
44-
</xsd:sequence>
45-
</xsd:complexType>
46-
</xsd:element>
35+
<xsd:element name="GetBook">
36+
<xsd:complexType>
37+
<xsd:sequence>
38+
<xsd:element name="ID" type="xsd:string"/>
39+
</xsd:sequence>
40+
</xsd:complexType>
41+
</xsd:element>
42+
<xsd:element name="GetBookResponse">
43+
<xsd:complexType>
44+
<xsd:sequence>
45+
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="1"/>
46+
</xsd:sequence>
47+
</xsd:complexType>
48+
</xsd:element>
4749

48-
<xsd:element name="AddBook">
49-
<xsd:complexType>
50-
<xsd:sequence>
51-
<xsd:element ref="tns:Book" minOccurs="1" maxOccurs="1"/>
52-
</xsd:sequence>
53-
</xsd:complexType>
54-
</xsd:element>
55-
<xsd:element name="AddBookResponse">
56-
<xsd:complexType>
57-
<xsd:sequence>
58-
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="1"/>
59-
</xsd:sequence>
60-
</xsd:complexType>
61-
</xsd:element>
62-
<xsd:element name="GetAllBooks">
63-
<xsd:complexType />
64-
</xsd:element>
65-
<xsd:element name="GetAllBooksResponse">
66-
<xsd:complexType>
67-
<xsd:sequence>
68-
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="unbounded"/>
69-
</xsd:sequence>
70-
</xsd:complexType>
71-
</xsd:element>
72-
</xsd:schema>
73-
</wsdl:types>
50+
<xsd:element name="AddBook">
51+
<xsd:complexType>
52+
<xsd:sequence>
53+
<xsd:element ref="tns:Book" minOccurs="1" maxOccurs="1"/>
54+
</xsd:sequence>
55+
</xsd:complexType>
56+
</xsd:element>
57+
<xsd:element name="AddBookResponse">
58+
<xsd:complexType>
59+
<xsd:sequence>
60+
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="1"/>
61+
</xsd:sequence>
62+
</xsd:complexType>
63+
</xsd:element>
64+
<xsd:element name="GetAllBooks">
65+
<xsd:complexType/>
66+
</xsd:element>
67+
<xsd:element name="GetAllBooksResponse">
68+
<xsd:complexType>
69+
<xsd:sequence>
70+
<xsd:element ref="tns:Book" minOccurs="0" maxOccurs="unbounded"/>
71+
</xsd:sequence>
72+
</xsd:complexType>
73+
</xsd:element>
74+
</xsd:schema>
75+
</wsdl:types>
7476

7577

76-
<!--
77-
A wsdl `message` element is used to define a message
78-
exchanged between a web service, consisting of zero
79-
or more `part`s.
80-
-->
78+
<!--
79+
A wsdl `message` element is used to define a message
80+
exchanged between a web service, consisting of zero
81+
or more `part`s.
82+
-->
8183

82-
<wsdl:message name="GetBookRequest">
83-
<wsdl:part element="tns:GetBook" name="parameters" />
84-
</wsdl:message>
85-
<wsdl:message name="GetBookResponse">
86-
<wsdl:part element="tns:GetBookResponse" name="parameters" />
87-
</wsdl:message>
88-
<wsdl:message name="AddBookRequest">
89-
<wsdl:part name="parameters" element="tns:AddBook"></wsdl:part>
90-
</wsdl:message>
91-
<wsdl:message name="AddBookResponse">
92-
<wsdl:part name="parameters" element="tns:AddBookResponse"></wsdl:part>
93-
</wsdl:message>
94-
<wsdl:message name="GetAllBooksRequest">
95-
<wsdl:part name="parameters" element="tns:GetAllBooks"></wsdl:part>
96-
</wsdl:message>
97-
<wsdl:message name="GetAllBooksResponse">
98-
<wsdl:part name="parameters" element="tns:GetAllBooksResponse"></wsdl:part>
99-
</wsdl:message>
84+
<wsdl:message name="GetBookRequest">
85+
<wsdl:part element="tns:GetBook" name="parameters"/>
86+
</wsdl:message>
87+
<wsdl:message name="GetBookResponse">
88+
<wsdl:part element="tns:GetBookResponse" name="parameters"/>
89+
</wsdl:message>
90+
<wsdl:message name="AddBookRequest">
91+
<wsdl:part name="parameters" element="tns:AddBook"></wsdl:part>
92+
</wsdl:message>
93+
<wsdl:message name="AddBookResponse">
94+
<wsdl:part name="parameters" element="tns:AddBookResponse"></wsdl:part>
95+
</wsdl:message>
96+
<wsdl:message name="GetAllBooksRequest">
97+
<wsdl:part name="parameters" element="tns:GetAllBooks"></wsdl:part>
98+
</wsdl:message>
99+
<wsdl:message name="GetAllBooksResponse">
100+
<wsdl:part name="parameters" element="tns:GetAllBooksResponse"></wsdl:part>
101+
</wsdl:message>
100102

101-
<!--
102-
A WSDL `portType` is used to combine multiple `message`s
103-
(e.g. input, output) into a single operation.
103+
<!--
104+
A WSDL `portType` is used to combine multiple `message`s
105+
(e.g. input, output) into a single operation.
104106
105-
Here we define three synchronous (input/output) operations
106-
and the `message`s that must be used for each.
107-
-->
108-
<wsdl:portType name="BookService">
109-
<wsdl:operation name="GetBook">
110-
<wsdl:input message="tns:GetBookRequest" />
111-
<wsdl:output message="tns:GetBookResponse" />
112-
</wsdl:operation>
113-
<wsdl:operation name="AddBook">
114-
<wsdl:input message="tns:AddBookRequest"></wsdl:input>
115-
<wsdl:output message="tns:AddBookResponse"></wsdl:output>
116-
</wsdl:operation>
117-
<wsdl:operation name="GetAllBooks">
118-
<wsdl:input message="tns:GetAllBooksRequest"></wsdl:input>
119-
<wsdl:output message="tns:GetAllBooksResponse"></wsdl:output>
120-
</wsdl:operation>
121-
</wsdl:portType>
107+
Here we define three synchronous (input/output) operations
108+
and the `message`s that must be used for each.
109+
-->
110+
<wsdl:portType name="BookService">
111+
<wsdl:operation name="GetBook">
112+
<wsdl:input message="tns:GetBookRequest"/>
113+
<wsdl:output message="tns:GetBookResponse"/>
114+
</wsdl:operation>
115+
<wsdl:operation name="AddBook">
116+
<wsdl:input message="tns:AddBookRequest"></wsdl:input>
117+
<wsdl:output message="tns:AddBookResponse"></wsdl:output>
118+
</wsdl:operation>
119+
<wsdl:operation name="GetAllBooks">
120+
<wsdl:input message="tns:GetAllBooksRequest"></wsdl:input>
121+
<wsdl:output message="tns:GetAllBooksResponse"></wsdl:output>
122+
</wsdl:operation>
123+
</wsdl:portType>
122124

123-
<!--
124-
The `binding` element defines exactly how each
125-
`operation` will take place over the network.
126-
In this case, we are using SOAP.
127-
-->
128-
<wsdl:binding name="BookServiceSOAP" type="tns:BookService">
129-
<soap:binding style="document"
130-
transport="http://schemas.xmlsoap.org/soap/http" />
131-
<wsdl:operation name="GetBook">
132-
<soap:operation soapAction="http://www.cleverbuilder.com/BookService/GetBook" />
133-
<wsdl:input>
134-
<soap:body use="literal" />
135-
</wsdl:input>
136-
<wsdl:output>
137-
<soap:body use="literal" />
138-
</wsdl:output>
139-
</wsdl:operation>
140-
<wsdl:operation name="AddBook">
141-
<soap:operation soapAction="http://www.cleverbuilder.com/BookService/AddBook" />
142-
<wsdl:input>
143-
<soap:body use="literal" />
144-
</wsdl:input>
145-
<wsdl:output>
146-
<soap:body use="literal" />
147-
</wsdl:output>
148-
</wsdl:operation>
149-
<wsdl:operation name="GetAllBooks">
150-
<soap:operation
151-
soapAction="http://www.cleverbuilder.com/BookService/GetAllBooks" />
152-
<wsdl:input>
153-
<soap:body use="literal" />
154-
</wsdl:input>
155-
<wsdl:output>
156-
<soap:body use="literal" />
157-
</wsdl:output>
158-
</wsdl:operation>
159-
</wsdl:binding>
125+
<!--
126+
The `binding` element defines exactly how each
127+
`operation` will take place over the network.
128+
In this case, we are using SOAP.
129+
-->
130+
<wsdl:binding name="BookServiceSOAP" type="tns:BookService">
131+
<soap:binding style="document"
132+
transport="http://schemas.xmlsoap.org/soap/http"/>
133+
<wsdl:operation name="GetBook">
134+
<soap:operation
135+
soapAction="http://www.cleverbuilder.com/BookService/GetBook"/>
136+
<wsdl:input>
137+
<soap:body use="literal"/>
138+
</wsdl:input>
139+
<wsdl:output>
140+
<soap:body use="literal"/>
141+
</wsdl:output>
142+
</wsdl:operation>
143+
<wsdl:operation name="AddBook">
144+
<soap:operation
145+
soapAction="http://www.cleverbuilder.com/BookService/AddBook"/>
146+
<wsdl:input>
147+
<soap:body use="literal"/>
148+
</wsdl:input>
149+
<wsdl:output>
150+
<soap:body use="literal"/>
151+
</wsdl:output>
152+
</wsdl:operation>
153+
<wsdl:operation name="GetAllBooks">
154+
<soap:operation
155+
soapAction="http://www.cleverbuilder.com/BookService/GetAllBooks"/>
156+
<wsdl:input>
157+
<soap:body use="literal"/>
158+
</wsdl:input>
159+
<wsdl:output>
160+
<soap:body use="literal"/>
161+
</wsdl:output>
162+
</wsdl:operation>
163+
</wsdl:binding>
160164

161-
<!--
162-
The `service` element finally says where the service
163-
can be accessed from - in other words, its endpoint.
164-
-->
165-
<wsdl:service name="BookService">
166-
<wsdl:port binding="tns:BookServiceSOAP" name="BookServiceSOAP">
167-
<soap:address location="http://www.example.org/BookService" />
168-
</wsdl:port>
169-
</wsdl:service>
165+
<!--
166+
The `service` element finally says where the service
167+
can be accessed from - in other words, its endpoint.
168+
-->
169+
<wsdl:service name="BookService">
170+
<wsdl:port binding="tns:BookServiceSOAP" name="BookServiceSOAP">
171+
<soap:address location="http://www.example.org/BookService"/>
172+
</wsdl:port>
173+
</wsdl:service>
170174
</wsdl:definitions>
171175

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
11
package com.cleverbuilder.cameldemos.core;
22

3-
public class PredicatesTest {
3+
import org.apache.camel.RoutesBuilder;
4+
import org.apache.camel.builder.RouteBuilder;
5+
import org.apache.camel.component.mock.MockEndpoint;
6+
import org.apache.camel.test.junit4.CamelTestSupport;
7+
import org.junit.Test;
8+
9+
public class PredicatesTest extends CamelTestSupport {
10+
11+
@Test
12+
public void testBodyIsNull() throws Exception {
13+
MockEndpoint isNull = getMockEndpoint("mock:bodyisnull-isnull");
14+
isNull.expectedMessageCount(1);
15+
16+
template.sendBodyAndHeader("direct:bodyisnulltest", null,
17+
"MyCustomHeader", "foo");
18+
19+
assertMockEndpointsSatisfied();
20+
21+
}
22+
23+
24+
@Override
25+
protected RoutesBuilder createRouteBuilder() throws Exception {
26+
return new RouteBuilder() {
27+
@Override
28+
public void configure() throws Exception {
29+
from("direct:bodyisnulltest")
30+
.choice().when(body().isNull())
31+
.to("mock:bodyisnull-isnull")
32+
.otherwise()
33+
.to("mock:bodyisnull-otherwise");
34+
}
35+
};
36+
}
437
}

simple-tests/src/test/java/com/cleverbuilder/cameldemos/scenarios/invokesoapservice/InvokeSoapServiceRouteBuilderTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ public void stopTestService() throws Exception {
3030
endpoint.stop();
3131
}
3232

33-
@EndpointInject(uri = "mock:output")
34-
MockEndpoint mockOutput;
33+
// @EndpointInject(uri = "mock:output")
34+
// MockEndpoint mockOutput;
3535

3636
@Test
3737
public void testInvokeSoapService() throws Exception {
38+
MockEndpoint mockOutput = getMockEndpoint("mock:output");
3839
mockOutput.expectedMessageCount(1);
3940

4041
template.sendBody("direct:start", null);

0 commit comments

Comments
 (0)