i am using postages Db for my services.When Null defined for any fields DSS giving Some object so my front end also getting same object .But they are expecting "NULL" instead of this they are getting {#nil":"true"}
How can i get NULL value As NULL only and its creating its own name space also for this row
http://www.w3.org/2001/XMLSchema-instance"
username password
=========== ============
NULL NULL
kk a123
for above i am getting like this fro WSO2dss side
<Datalist>
<username xmlns="http:sps.in" xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<password xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
</Datalist>
from my wso2esb side i am getting JSON like this
{"Body":{"Datalist":{"username":{"#nil":"true"},"password":{"#nil":"true"}}}}
But my front end service expecting in this below format where can modify for above this
{"Body":{"Datalist":{"username":"NULL","password":"NULL"}}}
In XML, the standard/recommended way to indicate that the value of a particular XML node is NULL, is via the notation [xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"]. If any standard XML parser comes across this particular notation, the element which contains the aforesaid notation is treated as an element with NULL as its value. This is particularly useful, when there are values such as "NULL" (not the actual NULL but a string containing the characters, "N","U","L","L") as there's no way to distinguish the real NULL values and "NULL" character streams.
Therefore, the best way to handle this scenario would be to check for #nil attribute at client side while parsing the JSON content that returns as the response of the web service invocation. Alternatively, you can add an XSLT transformation at the data service query level to transform the response (in XML format which gets processed internally within DSS before returning JSON content) the way you want so that you'll be able to add any custom rules and transform the response before it is returned to the client side. You can refer to the sample data service named "ExcelSampleService.dbs" located in "DSS_HOME/samples/dbs/excel/" directory in the product package for an example on how this is done.
Hope this helps!
Regards,
Prabath
It worked for me. I just put that two atributtes (xsi:nil, xmlns:xsi) into my XML by changing my AS (Application Server) like this:
public static OMElement addAttributeNull(OMElement parametro){
parametro.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance", null);
parametro.addAttribute("xsi:nil", "true", null);
return parametro;
}
Related
I have a case in BizTalk where I want to map an "Attribute Node" which type is Date that can't be null or empty and to avoid problems I need to suppress in the destination transformation map when the source is null.
I followed this link to try the same thing that we do with Nodes but doesn't answer my problem.
https://social.technet.microsoft.com/Forums/security/en-US/4ab184e0-c978-429c-a80d-e869732de8a2/how-to-suppress-empty-nodes-in-biztalk-map?forum=biztalkgeneral
Anyone have an idea?
Thank you,
Roberto
Edited
The link didn't mentioned that the Logical String returns True or Nill depending on your source.
I've obliged to check if is empty and as well null
From the source, connect to a Length Functoid, then Greater Than 1 Functoid.
Connect the Greater Than Functoid to the target.
However you end up composing it, connecting a Functoid that returns a boolean is treated as a create yes/no regardless of any value also mapped.
I am using the tESBConsumer component (using Talend Data Integration 6.4.1) to talk to a SOAP Web Service. We need to use a Web Service method that requires one of its parameters to be an array of strings, such that the payload needs to become something like:
"... <simpleParam>Simple Param Value</simpleParam><arrayOfStringsParam>
<string>Array
Item 1</string><string>Array Item
2</string><string>Array Item
3</string></arrayOfStringsParam> ..."
I cannot determine how to pass the array into the control to get it in the correct format. There is no type for Schema fields of String[].
I tried a type List but it got written out in the payload as something like:
"... <arrayOfStringsParam>[Array Item 1, Array Item 2,Array Item
3]</arrayOfStringsParam> ..."
.
I tried a type of String and formatted the data in previous steps as
"<string>Array Item 1</string><string>Array Item
2</string><string>Array Item 3</string>"
but in the resulting payload the less-than (<) signs got encoded to "<" so they weren't recognised as proper tags.
Can someone please let me know how to get this data in the appropriate format.
Thanks.
I'm trying to find a way to query Open Street Maps for a list of ATMs for a particular city, any ideas how to achieve this?
I know we can use mapquest to query for this information, but it needs a box and it gives me less informaton than Open Street Maps.
Thanks.
I guess you meant MapQuest's Nominatim instance. Just for the record: Nominatim is actually created by the OpenStreetMap community. MapQuest just runs it, too.
Querying for specific objects is best done by using the Overpass API. This API also has a nice frontend, overpass turbo. It makes creating queries and running them really easy and also includes a nice visualization of the result.
This query will retrieve all ATMs (which are tagged as amenity=atm) in Berlin:
<osm-script output="json" timeout="25">
<!-- fetch area “berlin” to search in -->
<id-query {{nominatimArea:berlin}} into="area"/>
<!-- gather results -->
<union>
<!-- query part for: “atm” -->
<query type="node">
<has-kv k="amenity" v="atm"/>
<area-query from="area"/>
</query>
</union>
<!-- print results -->
<print mode="body"/>
<recurse type="down"/>
<print mode="skeleton" order="quadtile"/>
</osm-script>
You can view the result on overpass turbo. This query has been automatically generated by overpass turbo, I just had to type "atm in Berlin" into it's wizard.
Note that this is a special overpass turbo query which cannot be run directly via the Overpass API. overpass turbo adds some extra keywords like {{nominatimArea:berlin}} which will be automatically replaced by the bounding box of Berlin returned by Nominatim. But if you already know the bbox or want to retrieve it on your own using Nominatim, then you can specify it directly:
<osm-script output="json" timeout="25">
<!-- gather results -->
<union>
<!-- query part for: “atm” -->
<query type="node">
<has-kv k="amenity" v="atm"/>
<bbox-query e="13.92242431640625" n="52.67221863915279" s="52.32778621884898" w="12.992706298828125"/>
</query>
</union>
<!-- print results -->
<print mode="body"/>
<recurse type="down"/>
<print mode="skeleton" order="quadtile"/>
</osm-script>
Both the Overpass API and overpass turbo support various output formats for the result, including XML and JSON.
I am using decide shape in orchestration and I receive 2 xml file.
and i have filter that file using xpatch because depend first node i have to process in different map. I use xpach statement to get find if the first node equal specific value if yes it will process if not it wil be send to second map.
how i should do that? I do not do it usually and try to find out how my statement should look
xpath(ACKSchema(name(/*))== CstmrPmtStsRpt;
How to check if xml file equal specific condition?
thanks
You can use the xpath query function to probe the value in the message, or set the value. The syntax for receiving a string value is
variable = xpath(BiztalkMessage,"string(xpath-query)");
To set a value in the message
xpath(BiztalkMessage,"xpath-query") = value
An easy way to locate the xpath you want to use is to open the schema in the Visual Studio BizTalk project, and select the node that will hold your value. Then look at the properties window and use the 'Instance Xpath' value (see this post for more details)
The xpath query can be a bit verbose, and depending on your situation you could shorten it (with a small loss of fidelity). If you are comparing a string value, you'll want to use the string function;
xpath(msgTestMessage,"string(//MyNode)") == "TestValue"
Without the xpath string function, you'll be receiving the equivalent of a nodeset, rather than the value.
You may not need to use the xpath and decide shape at all if your two xml files have different root nodes.
Using direct bound ports BizTalk can route your messages to the correct "subscriber" for you automatically. You drop the two input messages into the message box database. If you create one subscriber for each message type BizTalk will send the messages to the correct subscriber for you.
BizTalk uses the target namespace and the root node name to decide which subscriber gets which message.
I have the following state machine and I want this:
create a new order
add items into it (listing is optional)
confirm order by calling finish
pay for it
send it
And this flow is controlled via a REST web service and I'm not sure which method follows the REST principles better.
I came up with two possibilities (numbers below correspond with numbers above):
the first one - operation is specified by the path
1.
POST /create HTTP/1.1
2.
POST /addItem HTTP/1.1
<data>
<itemId>123</itemId>
</data>
GET /listItems HTTP/1.1
3.
POST /finish HTTP/1.1
4.
POST /pay HTTP/1.1
<data>
<price>123</price>
</data>
5.
POST /send HTTP/1.1
the second one - operation is specified in the body
1.
POST / HTTP/1.1
<data>
<operation>create.new.order</operation>
</data>
- returns resId
2.
PUT /{resId} HTTP/1.1
<data>
<itemId>123</itemId>
</data>
GET /items HTTP/1.1
3.
PUT /{resId} HTTP/1.1
<data>
<operation>finish.order</operation>
</data>
4.
PUT /{resId} HTTP/1.1
<data>
<price>123</price>
<operation>pay.order</operation>
</data>
5.
PUT /{resId} HTTP/1.1
<data>
<operation>send.order</operation>
</data>
The second solution seems better but I don't know if I can specify an operation in the request's body - is it ok or not?
Also I'm not sure if I should use PUT or POST at 3 and 5 in the second solution because I don't really update the resourse, I just change the state machine's state.
If none of these is correct how should I do it?
How about:
POST /orders
From that you get back a 201 Created response, along with a Content-Location header which specifies the URL of the just-created order, something like /orders/2876276
ok, then to add an item to an existing order:
POST /orders/2876276
The message can include url-encoded form data, specifying whatever you'd like to add to the order.
Then,
GET /orders/2876276
...gets some representation of the order. You could do content-type negotiation to figure out whether to format it as json, xml, or whatever. The response message would provide all the information about the order that you wish to share with the requester. Date received, status, order items, and so on.
I don't know what FINISH is exactly, but from my naive view it is just a special kind of update to the order item, so that is just another POST with special form data. After a POST with finish, the response to a GET will include a special indicator stating that the order is "complete."
To handle the payment, you may just use another POST on the same order. If your design calls for tracking accounts receivable, then you may have another object entirely. In other words if there is not one payment per order, but if a customer gets billed monthly or on some other rhythm, then you would have another object category like /accounts/39839. But in the simple case you could just use the order object to track payment state.
So, POST to an order URL to provide credit-card or paypal information to obtain payment. Subsequently, a GET will retrieve a representation that includes the order has been paid for.
The "Send" is not an HTTP request, I would think. Send is something YOU do to fulfill the order after receiving payment. Perhaps some system in your shop can post to /orders/872872872 to mark it sent. Subsequently, a GET will retrieve a representation that includes the order has been shipped, with maybe a tracking number.
I would be careful about using PUT. PUT indicates a insertion of an entire object into a repository, and implicit replacement if the object already exists. But your model doesn't call for that. The order manager manages the order, and exposes a limited set of operations (create, add item, etc) on each order. Insertion of an entire order is not one of those operations. Therefore PUT seems like the wrong thing in your scenario.
PUT would be right if you were inserting a document into a repository. For example imagine an auction where you offer an item for sale. You might use POST to create the auction item, then receive /items/29829 as the URL for the item. Then a PUT might be used to add an image to the item being auctioned - you might PUT to /items/29829/mainImage or something like that. PUT implies you know the URL of the thing to which you are PUT-ting.
you asked:
I don't know if I can specify an operation in the request's body - is it ok or not?
HTTP has only a limiited set of verbs. Your "order" object has a variety of states. You need to map the HTTP verbs to the state transitions. It makes sense to use POST to the order object for each state transition or state change. You might think of this as specifying "an operation" in the request body, but to me it is specifying the details of the request in the request body. This is precisely what the request body is for.
For more background, check out How to get a cup of coffee.