Change message name - web-services

Here is the part of my WSDL. I'm using the code first approach.
<portType name="MyWebService">
<operation name="echoString"/>
<input message="echoString"/>
<output message="echoStringResponse"/>
</operation>
</portType>
What annotation should I add or change so to change this
<input message="echoString"/>
to read as
<input message="echoStringRequest"/>
Thanks all.

I am quite surprised myself, but after trying for a while I looked into the spec and it seems you cannot really do this in jax-ws (except in a non-standard way, depending on the implementation). Here is what the jax-ws 2.0 specification says on this issue. See Java to WSDL 1.1 Mapping, Section 3.5, page 32:
The value of a wsdl:message element’s name attribute is not
significant but by convention it is normally equal to the
corresponding operation name for input messages and the operation name
concatenated with “Response” for output messages. Naming of fault
messages is described in section section 3.7.
So the only option that comes to my mind is to rename your operation, for example by changing or adding a #WebMethod annotation. Here is an example:
#WebMethod(operationName = "echoStringRequest")
public String echoString(String echoStringRequest) {
return echoStringRequest;
}
This will generate the following portType:
<portType name="MyWebService">
<operation name="echoStringRequest">
<input message="tns:echoStringRequest"></input>
<output message="tns:echoStringRequestResponse"></output>
</operation>
</portType>
The decision of whether you are more happy with this version is up to you.

I've encountered this problem myself recently and stumbled upon this thread multiple times. In our application we have a JAX-WS servlet which must use the format of ...Request and ...Response.
After a few days of searching, I found the solution.
Let's say your echoStringRequest has one String property that should be echoed back in the response.
class EchoMessage {
private String message;
//add getter and setter
}
First add this annotation to the web service class:
#SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
Then annotate your web service method like this:
#WebMethod
#WebResult(name = "echoStringResponse")
public EchoMessage echoString (#WebParam(name = "echoStringRequest") EchoMessage inputMessage) {
...
}
Without the parameterStyle BARE annotation, JAX-WS would automatically generate messages like this:
<echoString>
<echoStringRequest>
...
</echoStringRequest>
</echoString>
With the annotation, the outer element does not exist anymore.
The #WebParam and #ReturnType annotations are needed to determine the names of the root elements in the SOAP request and response body.

Related

CF Entity implicit getter putting space in front of number

I have the following object definition:
component persistent="true" table="settings" hint="Settings" extends="coldbox.system.orm.hibernate.ActiveEntity" {
property name="id" fieldtype="id" generator="native";
property name="type" ormtype="string" length="10" index="setting_type";
property name="name" ormtype="string" length="20" index="setting_name";
property name="ownerID" ormtype="integer" index="setting_ownerID";
property name="valueNumber" ormtype="float";
//return the appropriate value
public function getValue(){
return this.getValueNumber();
}
The problem I am having is that this.getValueNumber() is returning the number, but with spaces in front of it.
Wrapping it in trim() trim(this.getValueNumber()) doesn't remove the space before the number.
This doesn't seem to cause an issue when working with the number in CF, but it does when I place the number into a JS function and attempt to work with it in JS.
Has anyone come across this problem? Any way to stop it? It is happening on both cf9, cf10 and Railo 4.0.

Mocking a filter on unit tests of a flow in Mule

I have a flow that i want to test as follows:
<flow
name="MyFlow"
processingStrategy="synchronous">
<all>
<processor-chain>
<and-filter>
<filter ref="Filter1" />
<filter ref="Filter2" />
<filter ref="Filter3" />
</and-filter>
<!-- bla bla bla. doesnt matter for this question -->
</processor-chain>
<!-- more stuff that doesnt matter -->
</all>
</flow>
Filters 1, 2 and 3 are all custom filters.
I'm having a problem with filter 2 since it got some integration code that i can't replicate or execute on a unit testing enviroment. It would be great to tell my test just to accept that filter no matter what.
I just tried something like this (my test class is extending FunctionalTestCase):
muleContext.getRegistry().registerObject(
"Filter2",
new FilterThatJustAcceptsEverything());
But, that doesn't work.
Is there a way to mock that filter or some parts of its code just for this specific test?
This is how i'm calling it on my test method:
flow = muleContext.getRegistry().lookupObject(
"MyFlow");
String content = "bananas";
MuleEvent result = flow.process(getTestEvent(content));
Thanks in advance.
For mocking, the best way is to use munit - https://github.com/mulesoft/munit
Where you can mock the filter to just return the same event so it appears it just passes through. Something similar to:
whenMessageProcessor("expression-filter").withAttributes(...).thenReturnSameEvent();
Or alternatively, if you want to use the standard FunctionalTestCase, I would suggest using side-by-side configurations - http://www.mulesoft.org/documentation/display/current/Using+Side-by-Side+Configuration+Files and providing stub configurations.
It already looks like your filters are global. So what you can do is place your filters in a separate configuration "filters.xml" for example and provide a "filters-stubs.xml" in your test case. Where they can just be generic filters that always return true like so:
<expression-filter expression="#[true]" name="Filter1" />
and in your test load the stub config instead:
#Override
protected String getConfigResources()
{
return "main.xml, filters-stubs.xml";
}

Cas Ticket Issue in Jmeter

I have a web application which uses CAS Ticket for user authentication purpose which is different for every login. I recorded the script in JMeter. Also I correlated the pages by filling up the Regular Expression Extractor as follows:
Recorded script has url: https://foo.com/j_spring_cas_security_check?ticket=ST-3101-QDTyjbbHoOHvgPMdRBIg-cas.
After applying all above I ran the script but got status fail displaying https://foo.com/j_spring_cas_security_check?ticket=Ticket_Not_Found.
It would be very helpful if someone could tell me what did I miss in my script?
There is two ways for this,
if you have multiple username and password and you can use those with Jmeter,
you can use those to generate CAS ST(Service ticket).
Another:
default when CAS create ticket, it can be just used for one time.
you have to change values in ticketExpirationPolicies.xml of your cas server
to use same ticket multiple times.
default location is:
WEB_INF/spring-configuration/ticketExpirationPolicies.xml
change this to if you want 50 users to use same ticket
<!-- This argument is the time a ticket can exist before its considered expired. -->
<constructor-arg
index="1"
value="100000" />
</bean>
<bean id="grantingTicketExpirationPolicy" class="org.jasig.cas.ticket.support.TimeoutExpirationPolicy">
<!-- This argument is the time a ticket can exist before its considered expired. -->
<constructor-arg
index="0"
value="7200000" />
</bean>
Answer given by: VIVEK ADHIKARI
It seems that an error happened when fetching ticket value from url's parameter list. Maybe you can add a hidden field on your page and set its value from this parameter.
<input type="hidden" id="ticket_key" value="ST-3101-QDTyjbbHoOHvgPMdRBIg-cas" />
Then you can get it by Regular Extractor ticket_key=(.+)
Hope it helps.

Encoding of spaces in POJO parameters in Axis2

I have created a very simple service that just echos some text to the console. The service is just a POJO with a method echo, having a single parameter:
public class EchoTest
{
public void echo(String myMessage)
{
System.out.println(myMessage);
}
}
Ths is from the services.xml:
<service name="EchoTest">
<description>Echo test</description>
<parameter name="ServiceClass">EchoTest</parameter>
<operation name="echo">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
Further I use a very simple HTML form to submit the data to the service:
<html>
<body>
<form method="post" target="responseFrame" action="../../services/EchoTest/echo">
<input name="myMessage" type="text">
<input value="Send" type="submit"/>
</form>
<iframe width=500 height=500 name="responseFrame"></iframe>
</body>
</html>
The problem I have is that spaces are replaced with '+'. For example, if I type a message like this:
Hey you & you - # % #
The result is this:
Hey+you+&+you+-+#+%+#
Do I have to encode it somehow or or should it not behave like this? Or perhaps it is a setup issue? I am using Tomcat as a web container. For information, I use a servlet filter in Tomcat to e.g. filter on IP addresses, and in there I can see that the myMessage parameter looks OK, not having + signs.
It turns out that the problem was in fact within Axis2 itself. I am not sure exactly, but the version that I was using was release 1.5.1 from October 2009. What bugs me is that I have not found any bug report on it. It could be that it was fixed quickly and that I was unfortunate.
Upgrading to a the latest version of Axis2 solved the problem.

Resolve formatted table value in wix custom action

I've created certificate wix extension (extension of IisExtension). This includes a custom table, which is consumed by a custom action.
A column is defined as follows:
<columnDefinition name="Account" type="string" length="72"
primaryKey="yes" modularize="property" category="formatted"
description="..." />
This column contains values like "[Property]". When the custom action reads this column like this:
hr = WcaGetRecordString(hRecCertificate, vcpqAccount, &pwzTemp);
it get's the string "[Property]". But I need "PropertyValue". How can this string be resolved?
Regards Michael
WcaGetRecordFormattedString is what you're looking for.
I've not really used WcaGetRecrodString. Take a look at the MsiFormatRecord function. Check the return code and read all the gotchas on MSDN for tips on what might be going wrong.