using Websockets with Tomcat - java

I'm trying to make this example work
But when I deploy the war file to Tomcat and start it, the connection cannot be established.
In browser console I see that the client tries to connect to http://localhost:8080/Spring4WebSocket/add/info and receives 404, though the specified in start.jsp URL for connecting is /Spring4WebSocket/add (without that "/info" part in the end).
Why is this strange "/info" suffix added to the url and what can I do to change this and make this example work fine?
This solution wasn't helpful for me:
SockJs - 'info' path not found

The /info URL is called by SockJS (see docs):
...before the client starts the session. It's used to check server capabilities (websocket support, cookies requirement) and to get the value of "origin" setting (currently not used).
I looked at the example you are following and I don't see anything wrong with it. It follows closely a Spring guide: Using WebSocket to build an interactive web application so it should work.
Just one question though. Did you exactly follow the instructions or downloaded the zip file from the page or did you create it on your own? You get that error on the first SockJS request here:
var socket = new SockJS('/Spring4WebSocket/add');
Is your application also called Spring4WebSocket or something else? If it's called something else then use that instead:
var socket = new SockJS('/YourAppNameGoesHere/add');

Related

Blackboard Java Web Services error, using AXIS2 through SOAP - Security Header

I need to use Blackboard Web Services and I don't know how to establish a connection throught SOAP. I need something like Security Header. I read a lot, but always when I try to connect I get this kind of error.
I have a little big problem with this exception. Nothing is clear for me. I have nothing at the application log. I cannnot guess what should be the problem. I read also about AXIS2, Timestamps...
2016-03-08 20:53:58,739 ERROR edu.ku.it.si.registerproxytool.controller.RegisterToolController.registerProxyToolWithBlackboard:84 - There was an error in registering the tool: WSDoAllReceiver: Incoming message does not contain required Security header
Process finished with exit code 0
I'm looking to connect with a Blackboard web service through SOAP, and I can not send a correct Security Header
I read a lot about it, and finally I found this article. I'm using the project this guy post in the pdf. I have a Blackboard instance working at localhost on port 9876. I can do everything I want with it. It works fully.
I also tried to use SOAPui and I'm reaching a different error:
WSDoAllReceiver: security processing failed (actions mismatch)
I don't want to read more, I read more than 150 articles about it, and nothing.
Thanks :)
I have just started playing around with Blackboard web services, at the moment I am just accessing using SOAPui.
I am able to connect and send various functions, along the way I experienced the same error via SOAPui as you and so I found your question.
I overcame this error by doing the following:
Create a session using ContextWS.initialize, the username should be 'session' and the password 'nosession'. If successful this should return a token string.
Login using ContextWS.login. The username in the header should be 'session' and the password should be the token returned in 1. The userid and password in the body should be those of a user with sufficient web services permissions. If successful this should return 'true'.
Call whichever WS functions you wish. Always send the 'session' and token username and password in the header.
I found this here:
https://community.blackboard.com/docs/DOC-1116
I also found https://community.blackboard.com/thread/2147 and the linked youtube video useful to understand how to send the data correctly using SOAPui - you may need to change the wsdl url to https as SOAPui reverts it to a standard http. You also need to add a timestamp for every call.

OAuth Callback in the Glass Quick Starter Java App

Got my Glass last week. Working on running the Java version of the Quick Starter Glassware demo. I am having trouble with the OAuth callback. Do I need set this up myself? Or is there source included in the sample somewhere? Please help!
Clarification: I have set up my own project with the Java Quick Starter app's code, deployed it in EC2 and have set up the Client-ID and Client-secret in the Google APIs Console. I set the Redirect URI as http://<my server>/<my-app>/oauth2callback. When I visit the app in the browser, I get a 404 error that /oauth2callback is not found. I also tried setting the Redirect URI to just my app's root, i.e. http://<my server>/<my app>. Strangely, I still get the same error that /oauth2callback is not found.
Additional questions: Can you please clarify what the callback URL needs to be set to? Is the handler code already included in the quick-start-demo app or do I need to provide that code?
I think the problem is that you're not using a URL that actually maps to your server and servlet container. Try hitting the URLs directly from a browser and make sure they show up in your server and servlet container logs.
The callback url needs to be set to the oauth2callback servlet, relative to the path that leads to the server and servlet container. I don't know how you've set these up, so I can only guess, but it sounds like the <my app> portion isn't correct.
The handler code is included as part of the webapp. See the web.xml file to see the path mapping and the servlet object that it maps to. In this case, around line 53, oauth2callback is mapped to the com.google.glassware.AuthServlet class.
Update: See also the answer posted at Java Google glass starter project mapping in AWS EC2

Why is Apache https server is not sending the Port# in the URL?

I have a secure(https:443) application Running on Amazon Web services(AWS) have TOmcat7 and Apache http server to it.The URL looks like this https://ama.its.com/service. This works perfectly.
Their is a new requirement for cost effective alternative to run the development AWS instances of our Application on a non-standard ssl port like "23456". So the URL now becomes https://ama.its.com:23456/service. I have a Servlet implementation in our code. When i do a "request.getRequestURL().toString();"it returns the URL with out Port# https://ama.its.com/service. This is causing problems for my application. I want the URL to include the port# in it.
I googled on this a bit i saw this post. The Post tells that Apache server is masking the PORT and reconstructing the URL with out port. The post suggested a work around for getting the URL from the Request header, but i don't want to go that route now until i find out if their is a fix for it. I also looked in the Apache http logs if something funny is going on their. i couldn't find out anything suspicious.
Is their any way i can tell the server not to exclude the Port# in the URL?
Their is something buggy with Apache HTTP server when using a non standard ssl Port other that 443. When the URL is being sent the Port is stripped out in the request object. Alternatively getting the URL from the Request Header is a good option.
That option did not fit my needs as i have one website to the user but the Content i displayed in the Iframe of the website is actually loading the data on a different tomcat (Which is AWS server). So basically the request header gave the URL of the main URL than the URL of the website running inside of the iframe.
I have a workaround that fits to my project need to store the URL of the website with in the IFrame to get from a properties file and use it .

Inspecting request/response from Java/spring web service client

I have a client written in Java using the Springsource toolkit (that is, the #Service attribute) that is talking to an external webservice (completely seperate, nothing to do with my company) via HTTPS. I'm getting an exception on the marshalSendAndReceive step, which states that the content-type is coming back as text/html instead of the expected text/xml - with the message "could this be an error message?"
The webservice itself is the public test for the next version of the service, and calling the live service from the same code works fine. This particular method I am calling works fine on the live system but not on the test system.
My hunch is that the request is not correctly formatted for the test system - although only the response should have changed in the schema according to the release notes - and this is causing the service to return an error that is incorrectly parsed by my client. I am getting this error with all requests, even those that (according to the release notes) have not changed.
I have tried to use Fiddler and Wireshark to inspect the traffic, but can't get Fiddler to see it at all (I suspect this is a problem using Tomcat in STS with a proxy) and Wireshark can't decode the HTTPS stuff (I don't have the keys). I can't use HTTP, as the external service returns 403 Forbidden if I try.
I'm not the original developer, and I'm not even a Java developer. I am an experienced .NET developer, so any analogies with that will be understood - otherwise, I am a dummy and phrase your instructions/questions/possible help accordingly. As instructed by my predecessor, I have created a JAR file from the WSDL using XmlBeans and added that as a referenced library but I can't be sure that I've done that correctly, or even what it is that that is doing. It doesn't appear to have a discernable effect on things.
How can I debug this problem, and verify whether it is a problem with my client or their service?
My first goal would be getting Fiddler working. It is difficult to debug in the dark. However, where I get confused is when you discuss your client running in Tomcat in STS. Is your client a webapp?
Have you tried other tools like SoapUI to validate that the service is responding to your requests as expected?

Flex file upload with HTTPS and JAAS?

We're trying to upload a file from a flex client to a Java EE app.
In a full HTTPS environment
Java EE server is JBoss 5
Using BlazeDS 'Custom' authentication (username and password are entered trhough a flex form)
Using BlazeDS per session authentication
In regular AMF calls, we can access user principal and use role mecanism.
However, in our upload servlet, we have no access to user principal.
request.getUserPrincipal() // returns null
How to fix this ?
A while ago a guy commented on a blog post of mine that https + flex + firefox doesn't work:
have you tried uploading a file in firefox via https? Well, don’t bother, it can’t be done! Adobe blames it on firefox and puts their head in the sand. Read the teeth gnashing and ridiculous claims of Adobe here:
http://bugs.adobe.com/jira/browse/FP-201
Ultimately they threw up their hands and said it couldn’t be fixed, and, although said ‘We understand that this is a serious issue and are committed to resolving it’ suggested that either you:
1) Send the file to your server in a different way
2) Find another form of authentication
This may no longer be the case - register and see if the linked bug is still unresolved.
Also - this might not be your exact issue (at least not yet) - I'm just giving pointers.
From your post, and since I haven't used BlazeDS, I can't tell whether you're running into this issue specifically, but it sounds to me like you are --
Take a look at your server logs, or try using a Web debugger like Fiddler (you can tweak it to reveal HTTPS traffic in clear text), and you'll see that Flash blocks custom HTTP auth headers with FileReference.upload(). Why it does, I've no idea, but there's no workaround I know of, other than crafting something or your own manually.

Categories

Resources