Web-service reference in NetBeans project - java

I created .NET console WS-host. Now I'd like to create Java WS-client in NetBeans 8.0.
But I've faced to a problem. NetBeans returns an error in window: "Problem with downloading wsdl or schema file. Check the URL, proxy settings or whether the server is running. URL: http://localhost:8080/?wsdl."©
Also output: "Error: An I/O error occured. Server returned HTTP response code: 502 for URL: http://localhost:8080/?wsdl"©
I can open the URL in a browser. It's fine. Also .NET web-client works fine with the host.
Accidentally, I've used 127.0.0.1 instead of localhost in Chrome and IE. IE works fine and displays WSDL, but Chrome returns "Error Code: 502 Proxy Error."©
Where could be a problem?

So, the problem was resolved by changing of NetBeans Proxy Settings. I set it to No Proxy instead of Use System Proxy Settings.

Related

Spring websocket connection not being established

I followed this tutorial to build a spring websocket application. I've kept each file as it is but I'm neither using maven nor gradle. I run the index.html file on the tomcat server. When I click connect I get:
Opening Web Socket... GET http://localhost:8080/hello/info 404 (Not
Found) Whoops! Lost connection to undefined
in my Chrome's Developer window.
Why is this happening?
link may help. here I have given whole example.
for this you will require stomp.js, sockjs on your client side
and spring-websocket & spring-messaging 4.2.6.RELEASE jar in your server side,

WSDLException ... An error occurred trying to resolve schema ... Connection timed out: connect

First of all, my error is almost identical to what is reported in this question: WSDLException : An error occurred trying to resolve schema referenced at
Here is a snippet of my stack dump:
javax.wsdl.WSDLException: WSDLException (at /definitions/types/xs:schema/xs:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'http://www.w3.org/2005/05/xmlmime', relative to 'http://server.subdom.domain.com:13080/SM/7/Common.xsd'.: java.net.ConnectException: Connection timed out: connect] MDC{}
2015-05-24 14:36:33,751 ERROR (c.d.g.w.c.ContexteApplicatif.contextInitialized) [main] catching MDC{}
javax.xml.rpc.ServiceException: Error processing WSDL document:
javax.wsdl.WSDLException: WSDLException (at /definitions/types/xs:schema/xs:schema): faultCode=OTHER_ERROR: An error occurred trying to resolve schema referenced at 'http://www.w3.org/2005/05/xmlmime', relative to 'http://server.subdom.domain.com:13080/SM/7/Common.xsd'.: java.net.ConnectException: Connection timed out: connect
at org.apache.axis.client.Service.initService(Service.java:250) ~[axis-1.4.jar:?]
This occurs in my embedded Tomcat server running from within Eclipse. It is running on a Windows machine and there is an httpProxy at the system level. However, the URL is an internal address for which no proxy is needed. Anyhow, I implemented programmatically a proxy with the following code just before the reference to the WSDL file:
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "proxyhost.subdom.domain.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("https.proxyHost", "proxyhost.subdom.domain.com");
System.setProperty("https.proxyPort", "8080");
And now I am getting an HTTP 502 error which indicate a bad gateway. So, I suppose this solution is the wrong one since I shouldn't need a proxy in first place. I can access the page from within a browser, indistinctly if I enable or disable the proxy settings. In addition, there is a script to configure the proxy and if I use the proxy host shown above and hardcode it in my browser instead of "system proxy" or "automatic setting" I cannot access the page.
To summarize, it behaves like there is like it needs a proxy setup, however it doesn't. The problem is elsewhere and I have no idea how I can make significant progress to debug this problem.
Any hints? Something with Tomcat? Something with Eclipse?
I haven't tried yet on a standalone Tomcat server since my code is not yet ready for deployement.
NOTE: BTW, I tried the command from the quoted post and I am getting the same error as well. Connect timed out without system properties defined for the proxy and 502 code otherwise. At the same time, if I am launching the Web Service Explorer from Eclipse I am perfectly able to access the webservice and invoke operations.
Further investigation: I decided to use WireShark to see what is going on with the request and it appears both HTTP requests (the wsdl and the common types definitions) were fulfilled without a glitch and no connection timed out at all, not a single error. I can see the XML in WireShark and the HTTP status is 200 OK and everything is perfectly fine at this level.
So, what is going on here? I have the same problem on a Linux server while the message is a bit different. What wsdl2java is doing to believe there was a problem and abort?
After further investigation and testing with Axis2 and CXF, I finally found the problem, thanks to the CXF's version of the wsdl2java script which is giving a bit more details.
First of all, the original solution proposed was almost correct. I actually need to add all the proxy information, however I also needed to specify the non-proxy hosts otherwise I am getting the 502 error. The messages from the Axis script were not very detailed about the offending request, while CXF's version was very clear and enabled me to finally solve my problem.
So, in addition, if you modify the wsdl2java script, add -Dhttp.nonProxyHosts=... in addition to other options. The same thing if you need to specify a proxy programmatically.

Exception when submitting a form with recaptcha

I have created a web form which is having few input text fields and a recaptcha field. I am using http://www.google.com/recaptcha/api/verify url to verify the recaptcha input values. I've used connection.getInputStream() of java.net.URLConnection to get the responses. But when I submit the form I received below exception from the server at connection.getInputStream() point. I have googled for possible solutions but I was failed to find a suitable answer for the issue. What could be the possible reason for this?
Exception is:
Server returned HTTP response code: 502 for URL: http://www.google.com/recaptcha/api/verify
My application configurations are listed below:
Apache Tomcat 7.0.47
Struts2 framework
Application running OS is Windows 2003 server/32bit
Above url is not blocked by my firewall or gateway as the application worked fine when I was using jboss server. The issue occured when I migrated to Tomcat server. And also this exception doesn't occure frequently as well. Sometime it submit the form successfully but sometime it gives the above exception, couldn't figure out the pattern it occur. Kindly appreciate if anyone could help me on this.

Image getting 403 forbidden when deployed to server

Background:
I am using Spring web MVC along with JSP and HTML/JavaScript to write a website. I have added a search function, which sends a query to imdbapi.org and receives a JSON object containing movie/tv show information (via AJAX). The JSON object contains a "poster" field for each result, which is a URL to an image (on imdb server). The results are then displayed showing the poster if available, using jQuery..
someDiv.append($("<img src='"+results[i].poster+"'></img'").addClass("resultImg"));
Problem:
This works absolutely fine when running on STS built-in server and accessing locally eg.
http://localhost:8080/myWebPage.whatever
I have a ubuntu server box with Tomcat 7 installed, when deploying to the server I get a 403 error for each image. Example from chrome console:
GET http://ia.media-imdb.com/images/M/MV5BMTY2NDY4NDA0OV5BMl5BanBnXkFtZTcwNTI4MzUyMQ##._V1._SY317_CR5,0,214,317_.jpg 403 (Forbidden)
More Info:
Have tested in chrome and firefox with same results.
If I cannot fix then one solution would be to download to a temp folder on the server I think...
Is this a configuration problem on my box with the tomcat server?
Is this a configuration problem on my box with the tomcat server?
No, Not at all, Your server configuration has nothing to do with the external resource accessibility,If you are getting #._V1._SY317_CR5,0,214,317_.jpg 403 (Forbidden) - this clearly mean's that the server is refusing your request.
And it seem's many people's have these kind of problem with IMDB - see this
I have "made it work", it is not a direct solution to the question but a workaround. Using a local proxy on my server I download the image into memory in java and then return to the web page...
Java (server side)
#RequestMapping(value="/pages/proxyImg")
public ResponseEntity<byte[]> proxyImage(String url) {
log.info("Image Proxy server: " + url);
try {
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.IMAGE_JPEG);
return new ResponseEntity<byte[]>(IOUtils.toByteArray(new URL(url).openConnection().getInputStream()), headers, HttpStatus.CREATED);
} catch(Exception e) {
e.printStackTrace();
return null;
}
}
Javascript
someDiv.append($("<img src='"+"proxyImg.htm?url="+results[i].poster+"'></img'"));

Air application - faultCode:Client.Error.MessageSend

I have an AIR application that uses remote objects to communicate with the server. It works perfectly when the application connects to my localhost server. But as soon as I change the url to point to a remote test server, I get the following error:
fault.message: faultCode:Client.Error.MessageSend faultString:'Send failed'
faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP:
Failed: url: 'http://remoteserver:80/app/messagebroker/amf''
fault.name: Error
fault.faultcode: Client.Error.MessageSend
fault.faultstring: Send failed
fault.faultdetail: Channel.Connect.Failed error NetConnection.Call.Failed: HTTP:
Failed: url: 'http://remoteserver:80/app/messagebroker/amf'
What might cause this error? My local server is a glassfish 3.1, the remote one uses apache for load balancing in front of a glassfish.
When I navigate in the browser to the url of amf channel, it displays a blank page (which is fine).
I have also noticed that when I use tcp/ip monitor from eclipse, (I change the url to point to some port on localhost; tcp/ip monitor forwards the request to the remote server), the application works fine, no error occurs. Still, it appends a jsessionid to the url.
How can I resolve this issue?

Categories

Resources