You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/03/12 14:13:35 UTC

[GitHub] [camel-quarkus] ppalaga commented on a change in pull request #883: Add soap dataformat quarkus extension

ppalaga commented on a change in pull request #883: Add soap dataformat quarkus extension
URL: https://github.com/apache/camel-quarkus/pull/883#discussion_r391645384
 
 

 ##########
 File path: integration-tests/soap/src/main/java/org/apache/camel/quarkus/component/soap/it/SoapResource.java
 ##########
 @@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.soap.it;
+
+import java.net.URI;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.quarkus.component.soap.it.example.GetCustomersByName;
+import org.jboss.logging.Logger;
+
+@Path("/soap")
+@ApplicationScoped
+public class SoapResource {
+
+    private static final Logger LOG = Logger.getLogger(SoapResource.class);
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Path("/marshal")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.APPLICATION_XML)
+    public Response marshall(String message) throws Exception {
+        LOG.infof("Sending to soap: %s", message);
+        GetCustomersByName request = new GetCustomersByName();
+        request.setName(message);
+
+        final String response = producerTemplate.requestBody("direct:marshal", request, String.class);
+
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    @Path("/marshal-soap12")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.APPLICATION_XML)
+    public Response marshalSoap12(String message) throws Exception {
+        GetCustomersByName request = new GetCustomersByName();
+        request.setName(message);
+
+        final String response = producerTemplate.requestBody("direct:marshal-soap12", request, String.class);
+
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response)
+                .build();
+    }
+
+    @Path("/unmarshal")
+    @POST
+    @Consumes(MediaType.APPLICATION_XML)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response unmarshal(String message) throws Exception {
+        final GetCustomersByName response = producerTemplate.requestBody("direct:unmarshal", message, GetCustomersByName.class);
+
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response.getName())
+                .build();
+    }
+
+    @Path("/unmarshal-soap12")
+    @POST
+    @Consumes(MediaType.APPLICATION_XML)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response unmarshalSoap12(String message) throws Exception {
+        final GetCustomersByName response = producerTemplate.requestBody("direct:unmarshal-soap12", message,
+                GetCustomersByName.class);
+
+        return Response
+                .created(new URI("https://camel.apache.org/"))
+                .entity(response.getName())
+                .build();
+    }
+
+    @Path("/round")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public Response round(String message) throws Exception {
+        LOG.infof("Sending to soap: %s", message);
+        GetCustomersByName request = new GetCustomersByName();
+        request.setName(message);
+        final String xml = producerTemplate.requestBody("direct:marshal", request, String.class);
+        LOG.infof("Got response from marshal: %s", xml);
+
 
 Review comment:
   Unless /round is doing something not covered by the above /marshal /unmarshal endpoints, I'd vote for removing it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services