How to influence the reponse ws-addressing action element? - web-services

it seems that my response from a cxf implemented webservice contains a
<Action xmlns="http://www.w3.org/2005/08/addressing">urn://...dummy.../WebserviceResponse</Action>
Is there a way i can remove the urn and only keep the /WebserviceResponse or make the action empty?
<Action xmlns="http://www.w3.org/2005/08/addressing">/WebserviceResponse</Action>
The system that uses that uses our webservice fails on the urn on the action.

Got the answer via the CXF Mailinglist... All credits go to Daniel Kulp for providing the answer!
<quote>
If java first, you would need to add #Action annotations to the methods to
control the actions that are used and expected for the input and output (and
faults).
For wsdl first, you would need to add wsam:Action attributes to the
portType/operation/input and output elements. (which would result in the
above annotations being generated)
</quote>

Related

Update Status of an Order on Prestashop using Webservices

I just want to update the current_state of an order,
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<order>
<id>1</id>
<current_state>1</current_state>
</order>
</prestashop>
But the prestashop is asking me for all the mandatory fields of a Post when I use the put,
I tried using the exact same information than the put but it's loosing the total ammounts when I do the put,
Is there something wrong on prestashop architecture?
You must download all order information with get request. Then modify current_state field before make put request to update values. You can not just send only desired fields to update.
Check examples here: Prestashop Webservices Data Modification
Good luck
You can call the setWsCurrentState() on the order object. This function is defined in Order.php class file.
This function takes the ID of order state you want to set for the order.

Passing a colon (:) to a webservice in a browser (for testing)

I would like to pass a date string to a web service for testing, using a browser. I've tried Chrome and Firefox and both error out with this:
Server Error in '/' Application.
A potentially dangerous Request.Path value was detected from the client (:
The web service (RESTful) is accessed like this:
http://localhost:52936/Accounts/mod_date/2015-05-13T15%3A15%3A19
I've tried enclosing the date in quotes, but get the same error. Is this possible?
Try a QueryString Parameter
Since you are just performing testing, you should be able to pass your stringified DateTime value as a querystring parameter and it should avoid your service throwing a fit :
/Accounts/mod_date?yourDateParameterName=2015-05-13T15:15:19
Or if you wanted a more in-depth approach, you could consider using a suggestion like the one mentioned in this related discussion.
Explicitly Allow : Characters
Scott Hanselman covers the idea of explicitly allowing certain characters to be passed to a service via a URL in this blog post. It basically allows you to define which values are considered "dangerous" when passed in and would simply involve you changing the requestPathInvalidCharacters setting within the web.config of your application from :
<httpruntime requestvalidationmode="2.0">
requestPathInvalidCharacters="<,>,*,%,:,&,\"
/>
</httpruntime>
to :
<!-- Removes the colon ':' as a dangerous parameter -->
<httpruntime requestvalidationmode="2.0">
requestPathInvalidCharacters="<,>,*,%,&,\"
/>
</httpruntime>
This is obviously very controversial stuff and may not be useful for all scenarios, but it is an option.
Consider Postman (for Testing)
Additionally for testing purposes, you might consider using a service like Postman, which is ideal for performing this type of API testing.

Fusebox invoking a fuse within the code

Does anyone know if its possible to invoke a fuseaction within a coldfusion template?
(You haven't specified which Fusebox version; this answer applies to Fusebox 5.x)
Your title and question is asking two different things - a fuse and a fuseaction are two distinct things. A fuse is simply a CFML template, whilst a fuseaction represents a bundle of logic that performs a particular action (similar to a function).
Fuses:
To invoke a fuse, simply include the file as you would normally - there's no special FB functionality required for this.
Fuseactions:
To invoke a fuseaction, use the do verb, like so:
<cfset myFusebox.do('circuit.fuseaction') />
To store the result, use the second argument for the content variable:
<cfset myFusebox.do('circuit.fuseaction',varname) />
This is the equivalent of this XML:
<do action="circuit.fuseaction" contentvariable="varname" />
There are other arguments available, see this Fusebox cheat sheet which contains plenty of other useful info too.
With MVC, you should be working through a single entry-point. So only a single fuseaction should be called during your request.
BUT that fuseaction can call some of the other model and view templates as needed. And I believe that Fusebox allows you to refactor that logic into something that can be used by multiple actions. (I'm a bit rusty on my Fusebox functionality though, but I bet some Googling will lead you the way.)
As a dire last resort, you could use <cfhttp> to call a URL within your app that invokes that fuseaction. But why not just run some of the code directly without needing to burden your server with another HTTP call?

Converting complex SOAP requests to REST URIs

I am trying to create a REST web service which provides the exact same functionality as an existing SOAP based web service. Some soap requests can be quite complex and I am having trouble figuring out how these could be mapped to URIs. For example the following SOAP method body represents a search:
<HLRequest>
<HLSearch correlId=”1”>
<criteria numHLs="10" Level="AND" matchAll="true" exactHitCount="true" suppTemp="true" suppHLOnly="true" chainHLOnly="true" startDate="2011-01-01T00:00:00" endDate="2011-01-07T23:59:59">>
<symbols>
<symbol>CSCO</symbol>
<symbol>IBM</symbol>
<symbol>MSFT</symbol>
</symbols>
</criteria>
</HLSearch>
<HLSearch correlId=”2”>
<criteria numHLs="10">
<symbols>
<symbol>GOOG</symbol>
</symbols>
</criteria>
</HLSearch>
</HLRequest>
So I need to construct a method which handles URIs with an indefinite number of repeating query parameters and I'm not sure how/if this can be done within the REST paradigm.
Thanks in advance,
Ned
Your problem is that you're too hung up on a design pattern. There are things that REST is good for, and things that it's not good for, and you've just found one of the latter. You could come up with some scheme to map this data to a URI, but why would you want to? What problem would that solve? For this data, XML is probably the best way to represent it, so why not just post the XML?
Do you really need to map them all to URIs? A better approach for complex data is to make some json and post that. Apache CXF JAX-RS support can them automatically map that to bean classes.

How can I iterate recursively though a sharepoint list using webservices?

in sharepoint webservices, I can use getListItems() to obtain the child elements of a list.
In a document library, sometimes the element is a folder.
"ows_FSObjType = 1"
Is there any way to ask SP for the child elements of this folder?
Querying with getListItems() using the folder ID gives me a SOAP Exception.
Edit:
I found that this webservice has got more method
Site Data Webservice
There is an "enumerate folder" method, which has got a "isFolder" property, but no method to recurse its contents.
Thank you, Sam. :)
On the GetListItems method, one of the optional parameters is an XMLNode called "QueryOptions". One of the elements you can put in that node is <Folder>.
So you should be able to pass in something like:
<QueryOptions>
<Folder>/My/Path/Here</Folder>
</QueryOptions>
I may be off a bit syntatically (didn't try to build and run a query when making this post), but the general idea should be sound. You can see more details on this in the MSDN GetListItems Reference.