Skip to main content

Mobicents JAIN SLEE 2.0.0.GA released!

7 replies [Last post]
eduardomartins
Offline
Joined: 2005-10-10
Points: 0

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
harshaathreya
Offline
Joined: 2010-04-30
Points: 0

We are using Mobicents jboss-5.1.0.GA XDM server and using the xcap-client-api-2.0.0.GA.jar.

When sending requesting to server, we are getting http 403 error response. Here is the code snippet used by us for client-server communication:

XcapClient client = null;
URI xdmserverURI = null;
try {
client = new XcapClientImpl();
xdmserverURI = new URI("http://192.168.1.57:8080/mobicents");
Credentials credentials = null;
UsernamePasswordCredentials unamePwdCredentials = new UsernamePasswordCredentials("sip:eduardo@192.168.1.57", "password");
Header[] header = null;
//String content = "";
client.setAuthenticationCredentials(unamePwdCredentials);
//client.setDoAuthentication(true);

//UserDocumentUriKey key = new UserDocumentUriKey("resource-lists","sip:eduardo@192.168.1.57","retry");

String content = "" +
// "" +
// "
" +
//"
";
" "xmlns:rl=\"urn:ietf:params:xml:ns:resource-lists\""+
"xmlns:xsi=\"http://" +
"" +
"http://xcap.example.com/resource-lists/users" +
"/sip:joe@example.com/index/~~/resource-lists/list%5b@name=%22l1%22%5d
" +
"
" +
"
presence" +
"
" +
"
";

// send put request, application usage mimetype is needed

XcapResponse response = client.put(xdmserverURI,"application/resource-lists+xml", content, header, unamePwdCredentials);

Please give details as to why we are getting 403 response and what corrections are required for the client stub to get proper responses from server.

Thanks in advance
Harsha

eduardomartins
Offline
Joined: 2005-10-10
Points: 0

You're trying to put the document at URI("http://192.168.1.57:8080/mobicents") so you get a 403 forbidden back.

String userName = ...;
String documentName = ...;
String documentSelector = DocumentSelectorBuilder.getUserDocumentSelectorBuilder("resource-lists", userName, documentName).toPercentEncodedString();

UriBuilder uriBuilder = new UriBuilder()
.setSchemeAndAuthority("http://192.168.1.57:8080")
.setXcapRoot("/mobicents")
.setDocumentSelector(documentSelector);

URI documentURI = uriBuilder.toURI();

harshaathreya
Offline
Joined: 2010-04-30
Points: 0

Thanks!!!!

Made the changes as per your suggestions, still getting Http 403 response.

Please find the username and password used by us:

[i]String userName2 = "sip:bob@example.com";
String documentName = "index";
String documentSelector = documentSelectorBuilder.getUserDocumentSelectorBuilder("resource-lists", userName2, documentName).toPercentEncodedString();[/i]

Here are the details of the document content:

[i]String initialDocument =
"" +
"" +
"
" +
"
";[/i]

The question here is that are we using the right credentials (username and password) and the documentName. If not correct, please give details as to how to create the credentials on the server and the right docName to use.

Thanks
Harsha

harshaathreya
Offline
Joined: 2010-04-30
Points: 0

Or if u could send across a sample client program to connect to server and perform the put, get and delete operations, it will be really helpful for us.

Thanks
Harsha
[b]harsha.athreya@gmail.com[/b]

harshaathreya
Offline
Joined: 2010-04-30
Points: 0

Thanks Eduardo,

We got the client working and are able to perform PUT,DELETE and GET operations. The problem was with the credentials as the username and password was not created on the server. Created the same using the JBOSS JMX console and hence working fine.

Wanted one more help from you. Could you please share info with us as to how we can modify the Document using the PUT command.
For ex: If i want to update the list name="friends" to list name="pals", how this can acheived.

Thanks in advance.

Harsha

eduardomartins
Offline
Joined: 2005-10-10
Points: 0

Here is a code snippet that fully uses all URI part builders:

AttributeSelectorBuilder attributeSelectorBuilder = new AttributeSelectorBuilder("attrName");
String attributeSelector = attributeSelectorBuilder.toPercentEncodedString();
System.out.println("Attribute selector built: "+attributeSelector);

ElementSelectorBuilder elementSelectorBuilder = new ElementSelectorBuilder().appendStepByName("byName").appendStepByPos("byPos", 1).appendStepByAttr("byAttr", "attrName", "attrValue").appendStepByPosAttr("byPosAttr",1, "attrName", "attrValue");
String elementSelector = elementSelectorBuilder.toPercentEncodedString();
System.out.println("Element selector built: "+elementSelector);

NamespaceBindingsBuilder namespaceBindingsBuilder = new NamespaceBindingsBuilder().appendBinding("prefix1", "urn:test:namespace1-uri").appendBinding("prefix2", "urn:test:namespace2-uri");
String namespaceBindings = namespaceBindingsBuilder.toPercentEncodedString();
System.out.println("Namespace bindings built: "+namespaceBindings);

URI built = new UriBuilder()
.setSchemeAndAuthority("http://host")
.setXcapRoot("/xcapRoot")
.setDocumentSelector(documentSelector)
.setElementSelector(elementSelector)
.setTerminalSelector(attributeSelector)
.setNamespaceBindings(namespaceBindings)
.toURI();

Don't forget that on a attribute value put the mimetype is application/xcap-att+xml , and application/xcap-el+xml for an element put.

eduardomartins
Offline
Joined: 2005-10-10
Points: 0

By the way, next message please go to http://groups.google.com/group/mobicents-public , the java.net forums are not the official community for quite some time.