I am sharing how I make it work.
This is the xml formate you need to provide for login in XEN SERVER. So make XML as XEN SERVER expects and make a connection and post the xml. It will return the expected response.
<?xml version=’1.0’?> <methodCall>
<methodName>session.login_with_password</methodName> <params>
<param>
<value><string>user</string></value>
</param>
<param>
<value><string>passwd</string></value> </param>
</params>
</methodCall>
it you return a XML like
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>Status</name>
<value>Success</value>
</member>
<member>
<name>Value</name>
<value>OpaqueRef:XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
Then parse the XML to get the data and save necessary data for further use. You can have a good idea about XML formate and return type from XEN API Documentation
Best of luck. And feel free to ask any question.