My AXIS 1.4 web service uses complex type with one array and one string elements. When response does not contains arrays, everything is ok, bit when server should return an array, my SOAP response (SoapUI app) is completely empty. Request-response entities are generated with wsdl2java.
Any suggestions? Thanks.
Related
I have developed an API using .NET core 2.1; A function that should send email with attachments using multipart form data, needs to send toRecipients (email address) that should be filled as an array of email addresses.
The new function is developed but I am unable to call it from Postman as the array count in debug mode is equal 0 (not filled).
Please don't ask me to send files as binary as files must be sent as multipart.
How may I solve the issue and fill the array?
Below example of Postman:
Below example of model:
API input body:
Your toRecipients variable is set to be a List. The JSON value would be passed as a string[1], which you would need to deserialize in your .NET code.
You can check if the data is being passed properly via Postman using the Postman Console (View > Show Postman Console).
I'm not a .NET guy, but something like the following should work:.
Set the type for toRecipients to string in your code. You should receive the data properly then.
Next you should deserialize toRecipients in your code and store the result in some other variable (This would be the one which has the type as List<>)
I found this on MS's docs that should help: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to
[1] In HTTP everything is a string
I tried to get value from soap using Web Consumer, then I want to get the value with set-variable.
the problem, i can get the value to input in set-variabel.
this the design.
view image
Not sure if I understand your question, but I think you are trying to extract value from SOAP response. If this is the case, then note that Web Service consumer returns NamespaceRestorerXMLStreamReader.
You can drag "Transform Message" which is Mule DataWeave Transform Component from palette and drop it after Web Service Consumer component. You will then notice response structure in the left hand side. Define appropriate output format in right side and map the elements as needed.
You can then extract values to store in flow variable and continue with further logic.
Add a dom to xml the use xpath in a variable to pick the value
I am implementing pagination on a webservice. My first thought was to use query params page and size, like Spring Data.
However, we are basing some of our design on the google webservice apis. I notice that they use pagination tokens, with each page result containing a nextPageToken. What are the advantages to using this approach? Changing data? What kind of info would be encoded in such a token?
When paginating with an offset, inserts and deletes into the data between your requests will cause rows to be skipped or included twice. If you are able to keep track in the token of what you returned previously (via a key or whatever), you can guarantee you don't return the same result twice, even when there are inserts/deletes between requests.
I'm a little uncertain of how you would encode a token, but for a single tables at least it seems that you could use the an encoded version of the primary key as a limit. "I just returned everything before key=200. Next time I'll only return things after 200." I guess this assumes a new item inserted between requests 1 and 2 will be given a key greater than existing keys.
https://use-the-index-luke.com/no-offset
One reason opaque strings are used for pagination tokens is so that you can change how pagination is implemented without breaking your clients. A query param like a page(I assume you mean page number) is transparent to your client and allows them to make assumptions about it.
If I have a webservice that returns an image, is there a standard way to also have it return some structured data (in the simplest case, an additional string or number)?
See this question for a PHP example of a webservice that returns an image.
(But my question now is not specific to PHP.)
Possible solutions (mostly not very satisfying):
Put the extra data in the metadata of the image.
Put the extra data in the HTTP headers.
Have the webservice return a nonce URL from which the image can be fetched for a limited amount of time.
Base64-encode the image and make it huge string field in a JSON or XML data structure. (Thanks to Carles and Tiago.)
How would you do it?
(I don't really want to just split the webservice into two separate calls because the webservice takes a ton of parameters and it seems wasteful to send them all twice.)
HTTP headers are a viable choice as they can be parsed easily server side and client side. Another thing you can do is setup a 302 that redirects it to a URL with the image and data in the URL (e.g ->
hit http://mysite.com/bestimageever.png
get 302 to http://mysite.com/realbestimage.png?supercoolinfo=42
That'd be transparent to the user and most API clients will work (since they handle redirects)
Return the image's binary data encoded in base64, and the additional field:
{ image: "mIIerhdkwje...", data: "data" }
Base64 encoding gives you an overhead of 33% (you need 4 bytes for each 3 original bytes). Depending on the size of your data it may be better to replace this with the url of the binary data and issue a second request...
Protocol buffers are another choice. Protocol buffers aren't self-describing like XML or JSON, but they are much more compact on the wire. The Google library (http://code.google.com/p/protobuf) provides C++, Java, and Python libraries, and contributors have provided libraries for a lot of other languages (http://code.google.com/p/protobuf/wiki/ThirdPartyAddOns), including Javascript and PHP, so client writers should have an easy time working with the format.
isn't it possible to include the binary data to form the image inside the return json/xml? By this way, you could add as many fields as necessary and you could process this information in the client.
Simplified code example: http://pastebin.com/9ZQxSXi9
Hi
I wanted to experiment with the restlet 2.0 library and the gpodder webservice but somehow i reached a point where I can't see the wood for the trees.
The service in the example requires HTTP authentication and to post some JSON content to a URL.
Nothing that complicated but somehow even though the debug view claims the request object to contain the necessary content the RESTful webservice's response leads me to believe the HTTP header of the request was missing the content.
Any ideas on what's the reason? Thanks in advance.
The problem is that that none of the implementation of WriterRepresentation I've seen (JsonRepresentation, JacksonRepresentation, XStreamRepresentation) set the size of the representation when an object is passed. So if you create a new JacksonRepresentation(map) the size is not calculated.
You have to compute manually the length of the map content and calling Representation.setSize().
Or, as I did, use a
new JsonRepresentation(" a json string... ");
This constructor is able to compute the size, of course, that's the string length, so the proper content-length header is set and everything works smooth.