I have a mule xml that doesn't have a flow but using pattern to achieve the result.
How to unit test this pattern as flow is not present?
My xml looks like:
<mule>
<ws:proxy>
</ws:proxy
</mule>
I usually test my mule flows using a "black box" approach, and I do not execute my flows directly. Instead, I generate a web request directly using perhaps the Jersey HTTP client.
In your case, you probably want to make sure that the proxied web service is not called during your test. You can mock the service using the confluex-mock-http library or something similar.
Related
Question about Karate: can the .feature Mock files intercept calls from back-end Java service class?
I think the mocking feature is pretty easy to understand. I can see that you can start the mock server in the background step and then your scenario HTTP calls will be intercepted BUT
My question is: is it possible to intercept HTTP calls coming from my back-end service class after I hit my API endpoint with a Karate step?
If I don't get an answer, I will put together a sample project and experiment. Just hoping someone knows off-hand. If not, I think I can probably run an instance of Mountebank.
It may be possible by telling the JVM to use an HTTP proxy, but it depends a lot on the system under test.
You can find more details here: https://stackoverflow.com/a/61414022/143475
When should we use API Proxy against API AutoDiscovery. After implementing both, I found AutoDiscovery can also apply policies, analytics which API Gateway does, only thing is I cannot use a different url if using AutoDiscovery. Main advantage of API Proxy would be if my Gateway application and Mule Implementation Project is in different subnet, so if we are my Gateway server is compromised, no one can get to my implementation network.
But if both interface and implementation is in the same network, and purpose is just to call a REST Endpoint, should we not go with API AutoDiscovery.
Problems with Mule API Gateway Proxy
No defined way of Exception Handling, if we are not able to reach the Implementation Server.
No defined way of moving the Proxy Application across environments (CI/CD)
Extra HTTP Hops, can be acceptable if the above 2 issues have a defined way
Mule API AutoDiscovery
Since this is in the Mule Application, standard Exception Handling.
CI/CD is defined as it is the Mule Implementation Project.
No Extra HTTP Hop.
Only thing here is, we cannot change the implementation URL, that is only tightly coupled thing.
Can someone provide insight on when should we go for API Gateway vs AutoDiscovery. Also currently is there a way of doing Exception Handling in API Gateway Project and also CI / CD ?
API Autodiscovery is required if you plan to apply/unapply a policy to a particular endpoint, and/or take advantage of usage statistics in the context of API Platform. Api Autodiscovery is kind of metadata that links a HTTP(s) listener to its counterpart API version on API Manager.
For example:
<api-platform-gw:api id="api.basic.path" apiName="My API" version="1.0.0" flowRef="basic.path">
</api-platform-gw:api>
<flow name="basic.path">
<http:listener config-ref="a.http.config" />
<set-payload value="Endpoint successfully called." />
</flow>
Autogenerated Mule Proxies do have autodiscovery defined. You can also develop your own project and define the corresponding autodiscovery either by using the Studio UI, or handling the XML config directly.
The proxies are mean to be used in the case that your implementation backend is not a Mule application (for example, an existing REST based API hosted in a Tomcat server). You can enrich the logic with custom exception handling among other things on the Mule side. If you'd like better exception handling on the implementation backend, you will have to implement it there.
If your implementation backend is a Mule based application, using a proxy is not required. For most use cases, adding the corresponding autodiscovery element in the configuration file will do the trick.
Hello i have an soap service , in which a method will receive 2 input values and gives a bool O/P.
i am using web service consumer endpoint to consume this soap service. i want to understand what is the way i can send values to SOAP service .
`<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://.....?singleWsdl" service="ClientService" port="WSHttpBinding_IClientService" serviceAddress="http://....../ClientService.svc" doc:name="Web Service Consumer"/>
<ws:consumer config-ref="Web_Service_Consumer" operation="AuthenticateUser" doc:name="Web Service Consumer"/>
The web service consumer is very tipically used in conjunction with DataMapper, with it datamapper can pretty much visually construct a request for you. Given that DataMapper is an EE feature and you don't mention you have a license I suggest you changing approach and rather use the CXF module.
Based of the web service consumer documentation, the consumer is expecting the xml request of the service operation.
My quick suggestion is to use any tool to build the xml request based on the wsdl (such as SOAP UI) and use it in a set-payload, using MEL expressions to inject the two parameter values.
Hope it helps.
Please go through to get a better understanding on ws:consumer :- http://www.mulesoft.org/documentation/display/current/Web+Service+Consumer+Reference and http://www.mulesoft.org/documentation/display/current/Web+Service+Consumer
also there is an example in github:- https://github.com/mulesoft/mule-tooling-examples/blob/master/web-service-consumer/src/main/app/tshirt-service-consumer.xml
You can use <stdio:inbound-endpoint system="IN" doc:name="STDIO"/> to pass values to the service .. But I am not sure if it is a recommended approach ..
Another option is set-payload you can try to pass the value to the service
You can try this with this example
<ws:consumer-config name="Web_Service_Consumer"
wsdlLocation="somelocation_1.0.wsdl"
service="GreeterResponderService" port="GreeterResponderPort"
serviceAddress="http://user:password#localhost:8088/mockbinding"
doc:name="Web Service Consumer"/>
Hi I am working with Mule Studio and i am successfully running my flow in Mule Studio. I have certain issues related to implementation level since i have multiple flows in the one project.
How to deploy Mule as a REST Service with the existing flow.
If i am deploying my Mule as a REST Service what are the inputs i have to provide to make it run from the external HTTP Client based program.
When to use HTTP Client and when to use Mule Client. Which one fits where.
you can make use of RAML
1.create a RAML and generate the flows which internally referes your current flows
you can configure the Http details in generated flows
why you want to use http client and Mule client in your flows?
I want to use swagger for documenting our RESTful APIs. Our Jersey classes will be consumed from the mule flow. To use swagger for documenting my API I need to use the servlet configuration as mentioned in here - https://github.com/wordnik/swagger-core/wiki/Java-JAXRS-Quickstart
As the Jersey classes are deployed in mule, there is no web.XML.
If you know how to configure swagger with Mule please let me know how to do that. I truly appreciate your feedback and suggestions.
I see two possible options, the latter being the one with the highest chance of success:
Run a Servlet container inside Mule, as demonstrated by the bookstore example provided with the standalone distribution, configuring web.xml as indicated and making sure you're using servlet not http inbound endpoints in your Mule configuration.
Generate at build time a static Swagger configuration using https://github.com/ryankennedy/swagger-jaxrs-doclet and serve it using the static resource message processor from the HTTP transport.