I have a Java WS developed with JAX-WS. This service has only one method with two int parameters as input. Every time I try to call this service the parameters are 0. If I change to type to Integer 0 is transformed in null.
To figure these things out, you need to trace the messages into and out of the service. If it uses http, then consider a debugging HTTP Proxy like Fiddler2 or (I can't remember the Java version of the proxy). Fiddler2 is not written in Java but it works fine for Java-based apps.
If the service doesn't use HTTP then you'll need some other way to trace the messages.
Normally the problem here is one of XML schema agreement. An incorrect XML namespace on an incoming message will cause the input to be deserialized "null" or zero. Even a one character difference in the namespace - let's say a missing trailing slash - can cause this.
Related
This is going to be quite a hit or miss question as I don't really know which context or piece of code to give you as it is a situation of it works in local, which does!
The situation here is that I have several services, and there's a step where messages are put in a PubSub topic awaiting for the Dataflow consumer to handle them and save as .parquet files (I also have another one which sends that payload to a HTTP endpoint).
The thing is, the message in that service prior sending it to that PubSub topic seems to be correct, Stackdriver logs show all the chars as they should be.
However, when I'm going to check the final output in .parquet or in the HTTP endpoint I just see, for example h?? instead of hí, which seems pretty weird as running everything in local makes the output be correct.
I can only think about encoding server-wise when deploying the Dataflow as a job and not running in local.
Hope someone can shed some light in something this abstract.
The strange thing is that it works locally.
But as a workaround, the first thing that comes to mind is to use encoding.
Are you using at some point a function to convert your string input as bytes?
If yes, you could try to force getBytes() to use utf-8 encoding by passing by the argument like in the following example from this Stackoverflow thread:
byte[] bytes = string.getBytes("UTF-8");
// feed bytes to Base64
// get bytes from Base64
String string = new String(bytes, "UTF-8");
Also:
- Have you tried setting the parquet.enable.dictionary option?
- Are your original files written in utf-8 before conversion?
Google Cloud Dataflow (at least the Java SDK) replaces Spanish characters like 'ñ' or accents 'á','é',' etc with the symbol � since the default charset of the JVM installed on service workers is US-ASCII. So, if UTF-8 is not explicitly declared when you instantiate strings or their relative byte-arrays transformation, the platform default encoding will be used.
I have written a web service in java with axis2 and tomcat, and also a client in c# which I have successfully called methods on the web server with.
But I am struggling with a method, which has to be able to take in any Object as a parameter. A float, string, random file or picture.
I tried making a serializable object in c#, which I can create and put my String inside and then send it as a parameter to my web service funtion.
But I get: Exception thrown: 'System.InvalidOperationException' in System.Xml.dll
How should I solve this? I guess I have to serialize it first, but I dont get how I do that and then send the serialized object as a parameter to the function. And does this object have to be defined on the web service too?
You are going to run into problems if you want to send "any" C# object to Java. C# objects do not easily reduce to a Java object. They are different languages and each have some unique features in their object model. Instead, find an language neutral format (like Json) that can capture whatever type of data you need. Common data formats like Int, String, Boolean, etc are easily captured in JSon. More complex objects can be created as well with JSON.
So, I recommend the following. For each C# object you want to send across the wire, have it implement a toJson method, which takes it state and dumps it into JSON, transmit the JSON and deserilize as a Java Object. This should cover most cases.
I need a Firefox addon that would enable me to modify outbound http request headers thusly:
"[pseudocode] if any request header contains x in its content then replace x with y"
where x is a regular expression and y preferably can contain substitution patterns referencing x.
I've looked at the addons Tamper Data Modify Headers and Header Tool and none of them appear to support the above (Am I wrong?) "Header Tool" has some regex capability, but not apparently as specified above. Would greasemonkey or the like enable this? The only problem in my case is that the http request is actually sent out via an .swf (i.e. flash), though it is still displayed by say Tamper Data
(Note: If you think this query doesn't belong at stackoverflow, then please reference what stackexchange to use (though who other than programmers would be messing with reg expressions). This also isn't something to google, as
the first thing it returns is Header Tool which doesn't do what I want.)
It should be fairly trivial to write such an addon yourself if you don't need any GUI.
The SDK has a module (system-events) that requires only a few lines of code to hook into any and all HTTP requests or responses
Burp is not an FF addon but instead a java app but even the free version of it easily does what I described.
A "checkResult" service deployed on a node machine is defined to return the result on the node to a cluster controller that sends the request.The result on node ,which is in the form of file, may vary drastically in length,as is often the case with daily log files.
At first,i thought it might be ok just using a single string to pack the whole content of the file,so i defined
checkResult(inType *in,OutType *out)
where the OutType* is char*. Then i realized that the string could be in KB length or even more. So i wonder whether it is proper to use string here.
I googled a lot and could not find the max length permitted in wsdl(maybe conflict with the local maxbuffer length as well) and did not find any information about transferring a file type parameter either.
Using struct type may be suggested ,but it could be so nested for the file and difficult to parse when some of the elements inside could be nil and absent.
What'd you do when you need to return a file type result or large amount of data in a webservice?
p.s the server and client both in C.
When transferring a large amount of data in a (SOAP) web service request or response, it is generally better practice to use an attachment mechanism versus including the data as part of the body. Probably the order for considering attachment mechanism (broadest to narrowest adoption):
Message Transmission Optimization Mechanism (MTOM) - The newest of these specifications (http://www.w3.org/TR/soap12-mtom/) which is supported in many of the mainstream languages.
SOAP with Attachments - This specification (http://www.w3.org/TR/SOAP-attachments) has been around for many years and is supported in several languages but notably not by Microsoft.
Direct Internet Message Encapsulation (DIME) - This specification (http://bgp.potaroo.net/ietf/all-ids/draft-nielsen-dime-02.txt) was pushed by Microsoft and support has been provided in multiple languages/frameworks including java and .NET.
Ideally, you would be able to work with a framework to give you code stub generation directly from a WSDL indicating MTOM-based web service.
The critical parts of such a WSDL document include:
MTOM policy declaration
Policy application in the binding
Placeholder for the reference to the attachment in the types (schema) section
If you are working contract-first and have a WSDL in hand, the example in section 1.2 of this site (http://www.w3.org/Submission/WS-MTOMPolicy/) shows the simple additions to be made to declare and apply the MTOM policy. Appendix I of the same site shows an example of a schema element which allows a web service client or server to identify a reference to the MTOM attachment.
I have not implemented a web service or client in C, but a brief scan of recently-updated packages revealed gSoap (http://www.cs.fsu.edu/~engelen/soap.html) as a possibility for helping in your endeavors.
Give those documents a look and see if they help to advance your project.
I'm trying to consume a SharePoint webservice from ColdFusion via cfinvoke ('cause I don't want to deal with (read: parse) the SOAP response itself).
The SOAP response includes a byte-order-mark character (BOM), which produces the following exception in CF:
"Cannot perform web service invocation GetList.
The fault returned when invoking the web service operation is:
'AxisFault
faultCode: {http://www.w3.org/2003/05/soap-envelope}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Content is not allowed in prolog."
The standard for UTF-8 encoding optionally includes the BOM character (http://unicode.org/faq/utf_bom.html#29). Microsoft almost universally includes the BOM character with UTF-8 encoded streams . From what I can tell there’s no way to change that in IIS. The XML parser that JRun (ColdFusion) uses by default doesn’t handle the BOM character for UTF-8 encoded XML streams. So, it appears that the way to fix this is to change the XML parser used by JRun (http://www.bpurcell.org/blog/index.cfm?mode=entry&entry=942).
Adobe says that it doesn't handle the BOM character (see comments from anoynomous and halL on May 2nd and 5th).
http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_g-h_09.html#comments
I'm going to say that the answer to your question (is it possible?) is no. I don't know that definitively, but the poster who commented just above halL (in the comments on this page) gave a work-around for the problem -- so I assume it is possible to deal with when parsing manually.
You say that you're using CFInvoke because you don't want to deal with the soap response yourself. It looks like you don't have any choice.
As Adam Tuttle said already, the workaround is on the page that you linked to
<!--- Remove BOM from the start of the string, if it exists --->
<cfif Left(responseText, 1) EQ chr(65279)>
<cfset responseText = mid(xmlText, 2, len(responseText))>
</cfif>
It sounds like ColdFusion is using Apache Axis under the covers.
This doesn't apply exactly to your solution, but I've had to deal with this issue once before when consuming a .NET web service with Apache Axis/Java. The only solution I was able to find (since the owner of the web service was unwilling to change anything on his end) was to write a Handler class that Axis would plug into the pipeline which would delete the BOM from the message if it existed.
So perhaps it's possible to configure Axis through ColdFusion? If so you can add additional Handlers to the message handling flow.