lunedì 15 febbraio 2010

Xmbeans xml without XSD

I receive from a WebService an XML result. I didn’t have a XSD file for the xml, but by documentation and some try i figured out an XSD for generating Xmlbean bean for processing the result.

The problem is that the XML i received from the WebService didn’t have any reference to the XSD. So the XmlBean Documente generated from the XSD can’t parse the XML.

For resolving this you need to create an XmlOption object and pass it to the parse method.

 

Here an example. The Xsd namespace is http://myxsd.acme.it The root element of the XML is MY_RESPONSE.

XmlOptions options = new XmlOptions();
options.setLoadSubstituteNamespaces(Collections.singletonMap("",
    "http://myxsd.acme.it "));
options.setLoadReplaceDocumentElement(new javax.xml.namespace.QName(
    "http://myxsd.acme.it ", "MY_RESPONSE"));
MYRESPONSEDocument myResponseDocument = MYRESPONSEDocument.Factory
    .parse(xmlString options);

I worked this out  with the help of this mailing list thread: archive.com/user@xmlbeans.apache.org/msg03236.html

 

That’s all folks!

How to bypass Array SSL VPN

What I mean about bypass?  Not hacking the VPN and access machine that you haven’t the right to see, but let the machine with the opened VPN see outside or let the machine outside see the VPN.

This work for me with ArraySSL VPN, started from a web page. I think this can work with other VPN that start from a web page.

Why this how-to exists? Well, sometimes when you open a VPN, you can’t access your local network, but only IP on the VPN you have privilege to see. This didn’t always happen, I think depends the VPN setting that are outside client control.

First hint in this case, if you want to access outside the VPN while connected, is to create a virtual machine (I use Microsoft Virtual PC, not the 2007 version, but you can use whatever you want) and use the VPN inside the VM.

This work flawless, but if you want to access the VPN from outside the VM you can’t.

This can be a problem, for example, if your developer machine must access the webservice that the VPN expose.

I connect to the VPN from a web page. I log in, then an ActiveX is downloaded and the VPN is opened.

But I connect to the web by a proxy. When the VPN is open, the proxy must be accessible by the machine, so this particular machine in reachable. And even the Host machine can see the Virtual Machine.

Bingo.

I can tunnel any connection from the VPN outside the VM, and the host machine can expose to other machine.

Here the step. I assume you have a HOST machine (192.168.0.1). Inside it you have a Virtual Machine or VM (192.168.0.2) and you open the VPN on the VM.

  • Start the VM
  • Download Putty or PuttyPortable
  • Download FreeSSHd
  • Installing FreeSSHd on the HOST machine, enable authentication for somene user (or disable it), and enable the local port forwarding tunneling. You must not force to forward to localhost only.
  • Installing Putty on the HOSTmachine (you can try the portable version, if you don’t want to dirty the host machine)
  • Installing FreeSSHd on the VM machine, enable authentication for someone user (or disable it), and enable the local port forwarding tunneling. You must not force to forward to localhost only.

Now you have the HOST with FreeSSHd running and Putty. On the VM you have FreeSSHd running.

 

  • On the HOST machine, use Putty to make a connection (HttpProxyConnection) to the Host machine (localhost), tunneling the HTTP proxy server on one HOST port (4444 for example). Now the HOST machine can act like a HTTP proxy
  • On the HOST machine, use Putty to make another connection (VpnTunnelingConnection) to the VM  machine (192.0.0.2), tunneling the IP and port you need from the VPN. For every service select a port.
  • On the VM change the proxy to refer the HOST machine. If the HOST machine IP is 192.168.0.1 you use the proxy 192.168.0.1 with the port forwarded before (4444). You must use the IP instead of the Host machine name because when the VPN is on, the VM machine cannot access the WINS/DNS on the original network.
  • Now on the VM connect to the VPN by the web page.

Now on the HOST machine you can access the service behind the VPN (through the port you have chosen). The HOST machine can even expose the service for other machine in the network.

It’s a little hard the first time you try it, but it works great.

I have automated the process to make the two Putty connection on the HOST machine with a little batch file.  The load parameter refer to a saved session in Putty. The hard thing here, is Putty exit with an error if you try to connect while another instance of  Putty is trying to connect. The choice code wait five second (enough on my system, I hope in yours too ;-) before starting the second instance of Putty

 

@ECHO OFF

start  /b /min ..\PuTTYPortable\PuTTYPortable.exe -load "localhost_proxy" -l hostuser -pw hostpwd
ECHO .
ECHO Started localhost proxy
ECHO .
ECHO Waiting 5 seconds
ECHO .
choice /T 5 /C wait /D t  /M "wait 5 seconds" > NUL

start  /b /min ..\PuTTYPortable\PuTTYPortable.exe -load "my_vpn" -l vmuser -pw vmpassword

ECHO Started vpn tunneling
ECHO .
pause

exit

That’s all folks!

domenica 3 gennaio 2010

Without them

From Seth godin Blog
Without them

One of the most common things I hear is, "I'd like to do something remarkable like that, but my xyz won't let me." Where xyz = my boss, my publisher, my partner, my licensor, my franchisor, etc.

Well, you can fail by going along with that and not doing it, or you can do it, cause a ruckus and work things out later.

In my experience, once it's clear you're willing (not just willing, but itching, moving, and yes, implementing) without them, things start to happen. People are rarely willing to step up and stop you, and often just waiting to follow someone crazy enough to actually do something.

I'm going. Come along if you like.

sabato 2 gennaio 2010

Little rule

1. Don’t overthink.
2. Just start.
3. Forget perfection.
4. Don’t mistake motion for action.
5. Focus on the important actions. Clear the distractions. Pick the one most important thing you must do today, and focus on that. Exclusively. When you’re done with that, repeat the process.
6. Move slowly, consciously.
7. Take small steps.
8. Negative thinking gets you nowhere.
9. Meetings aren’t action.
10. Talking (usually) isn’t action.
11. Planning isn’t action.
12. Reading about it isn’t action.
13. Sometimes, inaction is better.


From the minimal blog