I am trying to write a mule munit test (in java) and I would like to check whether the message passed (or in this case exited) through a specific outbound-endpoint since there is routing in the flow and the message can pass through different ones depending on conditions?
My setup is to actually use 2 different flow files, one with the flow logic which uses generic endpoints such as
<outbound-endpoint ref="out.endpoint" />
And then another flow file with the actual endpoint definition such as
<vm:endpoint name="out.endpoint" path="out.path" />
The following java code works
verifyCallOfMessageProcessor("outbound-endpoint").times(1);
However I'd like to be able to specify the specific name of the endpoint. I have tried the following but none worked
verifyCallOfMessageProcessor("outbound-endpoint").withAttributes(attribute("name").withValue("out.endpoint")).times(1);
verifyCallOfMessageProcessor("outbound-endpoint").withAttributes(attribute("ref").withValue("out.endpoint")).times(1);
verifyCallOfMessageProcessor("endpoint").withAttributes(attribute("name").withValue("out.endpoint")).times(1);
verifyCallOfMessageProcessor("endpoint").withAttributes(attribute("ref").withValue("out.endpoint")).times(1);
All these 4 (Which are the ones that would make any sense to me) fail. Does anybody know how to accomplish this (Preferably through java otherwise using xml)?
This should be the way:
verifyCallOfMessageProcessor("outbound-endpoint").ofNamespace("vm").withAttributes(attribute("name").ofNamespace("doc").withValue("out.endpoint")).times(1);
Check that the attribute name has the namespace "doc.
Related
I'm developing a REST API using Restlet.
So far everything has been working just fine. However, I now encountered an issue with the Router mapping of URL to ServerResource.
I've got the following scenario:
GET /car returns a list of all cars
GET /car/{id} returns details about the car with id 1
GET /car/advancedsearch?param1=test should run a search across all cars with some parameters
The first two calls work without any problems. If I try to hit the third call though, the Restlet Router somehow maps it to the second one instead. How can I tell Restlet to instead use the third case?
My mapping is defined as follows:
router.attach("/car", CarListResource.class);
router.attach("/car/{id}", CarResource.class);
router.attach("/car/advancedsearch", CarSearchResource.class);
CarSearchResource is never invoked, but rather the request ends up in CarResource.
The router's default matching mode is set to Template.MODE_EQUALS, so that can't be causing it.
Does anyone have any further suggestions how I could fix it?
Please don't suggest to use /car with the parameters instead, as there's already another kind of search in place on that level. Also, I'm not in control of the API structure, so it has to remain as it is.
you need to add .setMatchingQuery(true); to that rout in order it to recognize that it is with a query at the end of it.
Router router = (Router) super.createInboundRoot();
TemplateRoute route1 = router.attach("/car/advancedsearch?{query_params}", MyResource.class);
route1.setMatchingQuery(true);
return router;
Mind that this pattern is with the exact specific order that you have determined in the route i.e. advancedsearch comes first and query_params comes after
I was able to solve this by simply reordering the attach statements:
router.attach("/car/advancedsearch", CarSearchResource.class);
router.attach("/car", CarListResource.class);
router.attach("/car/{id}", CarResource.class);
I'm using an XPage as an agent (XAgent) which makes an SSJS call into some Java classes stored as Java design elements. I want the processes which are instigated by the XPage to be in the context of the user I'm currently signed into the browser as. However everything seems to be running as me, I guess based on the last signature on the XPage?
For example, in my custom classes the following returns my name when I need it to be returning the user's name:
DominoUtils.getCurrentSession().getEffectiveUserName()
When using old school Domino agents, the effective username is determined by the "Run as Web User" or "Run on behalf of" fields in the agent properties.
Is it possible to achieve the same functionality when using an XPage?
To investigate you have a number of moving parts:
Add to the XAgent (not your Java code) a print statement with session.getUserName() and session.getEffectiveUsername()
Check your DominoUtils if there is a sessionAsSigner hidden in it
if 1 works, but not 3, consider dependency injection: instead of getting the session from DominoUtils hand it over as parameter from the XAgent to the Java class
Let us know how it goes
In my scenarios I could solve most of the requirements with either:
session.getEffectiveUserName()
or:
context.getUser().getFullName()
There are situations where you need to encapsulate this with:
session.createName(string):NotesName
to get the NotesName-Object representation.
I want to create endpoints that can be local in one setup and remote (via jms) in another.
What is the best approach?
I thought of creating my own component, 'abstract', then send to abstract:foo and in one setup have abstract:foo behave like direct:foo and in another setup behave like jms:queue:foo.
However, I'm not sure this is the cookbook approach and how to implement it exactly (how to do the "in one setup behave like X and in another behave like Y"), without being fragile (relying on different contents of META-INF/services/org/apache/camel/component/abstract in each setup)
So, what is the best approach?
You can use the camel PropertiesComponent for this. This allows to use placeholders in endpoints. See http://camel.apache.org/properties.html
E.g.
from("{{myendpoint}}")...
You can use a properties file in setup A to define "myendpoint=direct:foo" and "myendpoint=jms:queue:foo" in another case.
I found the best approach was to create a bean with my own schema name and have it create the desired endpoint (DirectEndpoint or other) according to properties
This may have already been answered and I just can't find it so feel free to point if needed.
I have a JAVA WSDL endpoint that I can successfully use to generate a reference. I have also used the WSDL sent from the programmers of this end point and again was successful in creating class files to use.
However when I create the objects needed to feed this service, in both cases, I receive an error that he cannot use the payload that I am sending.
Looking at it using the SoapUI tool it seems that his service is expecting some more information in the payload tags that does not seem to make into my classes.
Example: I can create <Tag1></Tag1> but he needs <init:Tag1></init:Tag1>
I don't know where the "init" prefix is getting dropped.
I am using VS 2010 and generating a simple web reference. Any tips would be helpful at this point.
The way I approach these problems is this:
use a same-technology client to connect to the service.
Trace the message on the wire. If ncessary strip out signatures and encryption so that you can get a readable XML message.
now, use the different-technology client (in this case .NET) to build client-side stubs and connect to the service. Trace the message on the wire.
Compare the two, and tweak the different-technology client to get it to match.
I use Fiddler2 to captures the traces of the HTTP messages. If you are not using HTTP then you will need something else.
Keep in mind, what you want is not string equality, but equivalence in the XML infoset.
An element like <init:Tx> may be equivalent to <Tx>, if the default namespace in the latter case matches the init namespace in the former. If you don't quite get what this means, then you need to read up on xml namespaces and get comfortable with the concepts.
In many many cases, I've found that it's XML namespace disagreement issues that cause the lack of interoperability. In one case I found that a missing slash on a namespace (http://foo/bar rather than http://foo/bar/) was enough to cause communication to fail. Figuring out what to tweak in order to get the actual message to match the requirement message is somewhat of a black art - I don't know how to explain it.
in some cases I resort to doctoring the WSDL document to get the different-technology client to do what I want.
good luck.
Yes I have since figured out that using the 4.0 svcutil.exe is the best thing in the world for seeing these issues. Again as I stated in a comment above, I figured out that it was merely a namespace issue and it wasn't .Net that was having the issue but the Java on the other end.
Hopfully this will make it easier to see usinf the specific 4.0 generator...
"%PROGRAMFILES%\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\svcutil.exe" /async http://SomeExternalWeb/ExtService.svc?wsdl /ct:System.Collections.Generic.List`1 /n:*,MyNS.Messaging.Services
I love the class generation over the reference generation any day.
while migration from weblogic WLI worflow to BPEL Human workflow, what is the option we have for jcx file for interacting with database.
any one please refer any document...
example; in my existing application we are selecting some values from database, in BPEL how we will achieve the same..
I am begineer in BPEL..
I have created a BPEL proces and data adapter inside that, now i want to execute that data adapter from my custom java code, is there any way to do the same.. pelase guide...
thanks
What versions are you working with? It is useful if you add more details about your set up.
Taking a wild guess, here is something that might help you:
Controls are exported as partner-links. The operations for this partner-link are derived from the methods in the control JCX file. Each method parameter is treated as a separate input message part; the name of the part is the same as the name of the parameter. The output message is determined from the return type of the control method. It has a single part called parameters, since a method has a single return type with no name.
http://download.oracle.com/docs/cd/E13214_01/wli/docs85/bpel/export.html#1061022
EDIT:
After a bit of research, I understand that you are on WLI 8.x. The link above should help you if you are facing problems exporting your JPD.
The alternate approach would be to import your 8.x project to 10g3 project, and export it from there. In this approach, you can generate BPEL2.0 compliant workflows. Warning: this is a one-time import, and the project will not be accessible via earlier WLI versions. So, try on a copy.
The second part of your question is not clear. Invoking controls from your Java code would be the same as invoking a web service. The WLI controls that are EJB calls/transformations get converted into web service portTypes. You can consume these web services from your Java application (eg., using Axis.)
Eg: If I am trying to convert a JPD SomeWorkflow.jpd, and if my JPD (WLI 8.x) had a control
/**
* #common:control
*/
private com.appmills.someapp.controls.TestDBCtrl dbctrl;
Or, alternatively with 10g3
#Control()
private com.appmills.someapp.controls.TestDBCtrl dbctrl;
The export creates three files SomeWorkflow.bpel, SomeWorkflow.wsdl and SomeWorkflow_ctrl.wsdl
The generated code would be:
<plnk:partnerLinkType name="com.appmills.someapp.controls.TestDBCtrl">
<plnk:role name="control">
<plnk:portType name="ctrl:com.appmills.someapp.controls.TestDBCtrlPT"
xmlns:ctrl="http://www.bea.com/workshop/bpel/ctrl"/>
</plnk:role>
</plnk:partnerLinkType>
EDIT 2:
The generated WSDL for controls (in the above example SomeWorkflow_ctrl.wsdl) does not contain <binding> or <service> tags. These are left out for you to define. The assumption is that you have these available somewhere, and have to simply wire them in.
As you might be aware of, the JCX equivalents in Oracle-SOA are JCAs. There is no direct export-import between WLI and Oracle-SOA. This means that there could be varying amount of efforts based on your current code complexity and your migration plan.
In my opinion, for JDBC Controls specifically, the simplest solution is to rewrite them as Database adapters.