Skip to content

Commit 4188e8c

Browse files
committed
A few fixes
1 parent 8bfa9c5 commit 4188e8c

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

examples/simple/README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,26 @@ mvn clean install -Pgrpc -f server/pom.xml
8888
mvn exec:java -f client/pom.xml -Prun-grpc -Duser.name=Kabir
8989
````
9090

91-
You should see the output: `Agent responds: Hello kabir`
91+
You should see the output: `Agent responds: Hello Kabir`
92+
93+
### HTTP+JSON/REST
94+
95+
1. Build the server
96+
````shell
97+
mvn clean install -Prest -f server/pom.xml
98+
````
99+
100+
2. Start the server
101+
102+
````shell
103+
./server/target/wildfly/bin/standalone.sh --stability=preview
104+
````
105+
106+
3. Run the client
107+
108+
````shell
109+
mvn exec:java -f client/pom.xml -Prun-rest -Duser.name=Kabir
110+
````
111+
112+
You should see the output: `Agent responds: Hello Kabir`
92113

examples/simple/client/src/main/java/org/wildfly/extras/a2a/examples/simple/client/SimpleExampleClient.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ public SimpleExampleClient(String protocol) throws A2AClientError, A2AClientExce
4545
ClientBuilder clientBuilder = Client.builder(agentCard)
4646
.clientConfig(config);
4747

48-
if (protocol.equals(TransportProtocol.JSONRPC.name())) {
49-
clientBuilder.withTransport(JSONRPCTransport.class, new JSONRPCTransportConfigBuilder());
50-
} else if (protocol.equals(TransportProtocol.HTTP_JSON.asString())) {
51-
clientBuilder.withTransport(RestTransport.class, new RestTransportConfigBuilder());
52-
} else {
53-
// 'target' comes from the AgentCard, and is populated by a2a-java
54-
clientBuilder.withTransport(
48+
TransportProtocol prot = TransportProtocol.fromString(protocol);
49+
switch (prot) {
50+
case JSONRPC -> clientBuilder.withTransport(JSONRPCTransport.class, new JSONRPCTransportConfigBuilder());
51+
case HTTP_JSON -> clientBuilder.withTransport(RestTransport.class, new RestTransportConfigBuilder());
52+
case GRPC -> clientBuilder.withTransport(
5553
GrpcTransport.class,
5654
new GrpcTransportConfigBuilder().channelFactory(
5755
target -> {

0 commit comments

Comments
 (0)