When using the WCF Test Client tool, if I invoke a method via eager loading like below:
.Include("entity name")
the client tool crashes with a "stackoverflow" exception.
If I make a call without the Include statement, it works fine.
Note that either way, if I execute them via another type of client, I can see in the WCF trace message log, that the data gets xferred just fine for both. It's just that the WCF client tool can't seem to handle calls via EnityFramework and eager loading when data from more than one entity is brought back.
I guess there is not a way around this error with this tool. Looks like I have to resort to testing with my other client making the call instead of simply invoking the method via the WCF test client tool.
Anyone see this same scenario. If so and if there is a work around, I'd appreciate it if you could let me know.
Related
I'm working on a codebase that attempts to make a REST call to a remote service, which returns JSON. The call works fine when it gets normal JSON back. In some cases, like when the network blows up, it gets back HTML, which tries to report various network problems.
Our error handling code in the client needs to deal properly with this situation, which is defined as simply obtaining the HTML string and logging it.
I find it's a little hard to write an automated test for this.
In our client code, we use ClientBuilder.newBuilder()... , then call "build()", which returns the Client, and then we call "client.target(url)" and then move forward with getting the response. We have an exception handler that will attempt to read the raw text.
In a test for this kind of thing, I'm used to using the CXF JAXRSServerFactoryBean class to run a server. I know how to connect the client to the server, but I'm not sure what to configure in the server to allow me to return arbitrary text, instead of a "resource class".
It's also possible that using JAXRSServerFactoryBean is overkill for this, as it just needs to return plain text.
What are my options here?
Update:
I did make progress setting up a test using JAXRSServerFactoryBean, but I'm still wondering if there are other options, especially ones that mitigate the next problem that I discovered, described at Using javax.ws.rs.client.ClientBuilder in CXF to create Client, any route to be able to use local transport? .
Update:
I gave up on the JAXRSServerFactoryBean approach, as I don't need to test the network, and doing so adds additional complications. The JAX-RS filter approach is simpler and avoids those complications. See the above linked question for details.
I am writing a web service in node, and testing it with Postman. I spent a long timing looking for an error. When I finally found it, it turned out to be a simple error formatting the response body, which is json.
If I leave off the final brace in the response body, Postman waits for two minutes, and then reports that it received everything, just fine.
If I leave off the closing quote in the last value in the json, Postman says the server didn't respond, perhaps I should check my security certificates.
I would much rather Postman said "Hey, Buddy, you left off a quote!"
If there some validation service I can talk to? Or a plugin in Postman?
Here there are some validation javascript libraries, you can use:
Validator provides a declarative way of validating javascript objects.
Express-validator acts as an express.js middleware for node-validator.
Meanwhile, Postman got API testing and Collection Runner that can help you through this; which you can write some pre-request script as well as test script for each request.
Also, they got Newman which is a command-line collection runner. It allows you to effortlessly run and test a Postman collection directly from the command-line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.
I found that Paw worked (https://paw.cloud/). And so far I haven't paid for it.
Where Postman said "check your security certificates," Paw said "we were expecting 376 bytes but you only sent us 312."
Cuts down my time solving the problem a lot!
I use Fiddler for this. It is very good at identifying (with an error message that pops up) problems and bad implementations of the HTTP protocol. Browse the web with it running, and within a few minutes you'll undoubtedly hit a poorly implemented server.
Postman won't be able to handle these cases since it's insulated from poor behavior by the browser's framework.
That's not your problem though.
When I finally found it, it turned out to be a simple error formatting the response body, which is json.
That has absolutely nothing to do with HTTP. HTTP doesn't know or care what your request/response bodies are.
The problem you face is that your API endpoint could be returning whatever it wants. You need a custom solution to your problem, as there is no standard API server in this case.
Most folks will run unit tests that hit common endpoints of your service to ensure they're alive and well.
I should also point out that it should be all but impossible for you to break the JSON response if you're doing it correctly. Sounds like you're serializing JSON manually... never do that, we have JSON serializers for this purpose. Send in an object and let it worry about building the JSON output for you. Otherwise, you'll waste a lot of time on problems like these.
Very new to WCF and almost got everything to work doing POST from JQuery to WCF. I thought?
The Jquery is processing a DynaTree and gets the latest dictionary which needs to be serialized in order to perform a successful post.
When I run Visual Studio, it works fine. When I access the site from my development machine - not in debug mode - it also works fine. But when accessing the site from any other machine siting on the same domain within the WLAN, it fails.
var dict = $("#tree").dynatree("getTree").toDict();
The line in particular that fails is JSON.stringify(dict);
The alerts shows an object coming through and hence toDict() works fine. However, when JSON tries to serialize it, fails.
This serialized data will be my post data to WCF handle. There is nothing wrong in WCF, the call to WCF is never made as the code fails one line above.
Need help.
I have implemented a WCF service (written in C#) that serves as a backend to a Webapp. The WCF is supposed to call stored procedures from a SQL database and return the data via JSON so it can be displayed in the WebApp. My issue is that the WCF service sometimes will return an empty JSON array. If I use the same parameters and execute the stored procedure using SQL Management Studio I get hundreds of rows returned. How can I debug this issue? I've been looking at Chrome's dev tools and Firebug and they both show that the request is being responded too (it's just empty).
Thanks for the help.
There's three main places you can debug:
Use the WCF test client to call the service directly rather than from front-end code.
Use SQL Server profiler to make sure your service is calling the sprocs with the parameters you expect.
Attach the debugger to your WCF service and step through the code.
Attach a debugger to the WCF service and see what happens to the result set provided by the DB.
New here. I've searched quite a bit for a working solution to my problem, but even though I have found posts with promising titles, none of the solutions have worked.
I am deploying an MVC2 web app to a client's server.
I did my development on Win2k8 Server, but they are running Win2k3 sever.
The app's only purpose is to receive some record ID information as HTTP parameters, check in the database for the status of the given record or records, and then return the status information as a simple string such as "Completed" or "Incomplete" in JSON format.
This getJSON code works fine in the development environment.
Inexplicably to me, on the client's server, the getJSON request receives a null response from the application.
There is no cross-domain action AFAIK... the result is the same from the client's server or from my machine via VPN.
In the MVC model's Json code, a common solution for people is to add the "JsonRequestBehavior.AllowGet" attribute to the Json result being returned. I did this long before trying to deploy it, and as I said, it has worked fine in the dev environment.
Using Firebug, I have watched the same request URL get sent to both my local server and the client server - the response headers from both servers are the same, but the response content from my server is shown as:
{"Result":"No Data"}
Which is what I want.
There is literally no content shown in the response from the client's server..? But the request gets an HTTP 200 code and is recorded as a success in the reponse's status attribute.
The response header content type in both situations is "application/json"
But wait, there is more!
If I manually enter the request to each server in the Firefox nav bar, and hit enter, in both cases it responds with:
{"Result":"No Data"}
Which is what I want. So why can I get the result I want from the MVC app on the client's server only when I hand-enter the request URL in Firefox, but not from the Javascript code?
I have tried forcing different output content types ... using the jQuery ajaxSetup method...
$.ajaxSetup({
async: false,
dataType: 'text'
});
or
$.ajaxSetup({
async: false,
dataType: 'html'
});
and again wtih 'script', and 'json'. I also tried the conversion options such as 'text json' or 'html json' or 'json text' and so forth.
Some of the posts I'm reading, and my gut feeling, though, suggest the problem is not the jQuery code making the request that is at fault... I don't see how the same jQuery request point to a different server running the same app would suddenly cause that server to send back a 'null' value.
By null, I want to be clear... I mean nothing is sent. There is no {} or {null} or any sign of JSON... just blank whiteness of non-existence :P
Even if nobody knows the answer, I would love some input perhaps suggesting where I should focus my sleuthing ... client or server?
If the problem is the server, it seems hard to really know that the MVC stuff is running 100% on the IIS6 server, but in general it seems to work. I have a different MVC app running on the client server which responds to the virtual paths, and generally runs the same as on dev machine.
I have found one thing ... the request headers are somewhat different? The Request Headers sent to the IIS7 setup include an "X-Requested-With: XMLHttpRequest", "referrer" , and "cookie" field/value.
I could guess that the lack of the "X-requested-with: XMLHttpRequest" in the IIS6 request headers is a clue, but I do not see then how the same javascript code pointing at a different server can generate different request headers itself. So how else are those being generated?
The javascript is embedded in an ASP.NET page, btw.
Oooh.. frustration!
Thanks for any input.
Odd Progress ... apparently there is some sort of issue with IIS6 handling the query. Although I have not payed any attention to JSONP, a post elsewhere suggested that sometimes use the "&callback=?" parameter at the end of a .getJSON request URL would force it into GET mode and that worked frequently for problems getting data from the server. So I did that... and it did work, sort of. The proper {"Result":"No Data"} was returned in response to the request... which seems good. However, the way that the JSONP callback works, it generates its own script to do the calling and fetching and interpreting of the incoming JSON. In this case, it interprets the JSON to need a label which it does not have, thus an error is thrown "invalid label" ... there must be some way to hack things to just deliver the JSON, but the whole required use of JSONP callbacks suggests that the server configuration is wrong, right? Or why does it work without JSONP for IIS7 and not IIS6?
Despite my not liking the callback JSONP solution, it appears to work ok. The error is still returned about an invalid label, but that does not appear to stop the remaining javascript from running... and so the application is working with IIS6 now. I have not tested the fix of using the callbacks and JSONP against IIS7 yet, but I expect it will work well enough.
Here is a link to the discussion that lead me to my current solution. I do still hope to find a more elegant solution, however.
NeoWin.net
Are you certain that your App Extension Mappings are set up correct?
Follow this article for running MVC2 on IIS6 and ensure all the different configurations have been done, that's probably the first step before going further and investigating specifics.
I'm really inclined to believe it's related to HTTP Verbs.