views:

40

answers:

1

Hi all. I'm using resteasy and have some problem.

There is some service on remote server. For example, when I go to url

"http://some.site.com/Login/my_login/my_passowrd" service returns me xml:

< LoginToken> < success>true< /success> < token>23324473-897b-408b-b096-bf2cddad33< /token> < /LoginToken>

I've wrote class for mapping:

@XmlRootElement(name = "LoginToken") public class LoginToken {

@XmlElement(name="success") private String success;

@XmlElement(name="token") private String token;

public String getSuccess() { return success; }

public String getToken() { return token; } }

..and another code for testing:

final String loginUrl "http://some.site.com/Login/{login}/{password}"; ResteasyProviderFactory instance = ResteasyProviderFactory.getInstance(); RegisterBuiltin.register(instance);

ClientRequestFactory client = new ClientRequestFactory();

LoginToken ct = client.get(loginUrl, LoginToken.class, "user", "123456");

System.out.println(ct.getSuccess() + " " + ct.getToken());

after running this example I receive result:

true 23324473-897b-408b-b096-bf2cddad33

But server can returns another xml:

< LoginToken xmlns="some.site.com/login/api/domain" mlns:i="http://www.w3.org/2001/XMLSchema-instance"> < success>true< /success> < token>23324473-897b-408b-b096-bf2cddad33< /token> < /LoginToken>

and i have unmarshall error:

Exception in thread "main" org.jboss.resteasy.plugins.providers.jaxb.JAXBUnmarshalException: javax.xml.bind.UnmarshalException: unexpected element (uri:"some.site.com/login/api/domain", local:"LoginToken"). Expected elements are <{}LoginToken> at org.jboss.resteasy.plugins.providers.jaxb.AbstractJAXBProvider.readFrom(AbstractJAXBProvider.java:86) at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105) at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:46) at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108) ...

Question: how can I map xml-namespace using resteasy? Please, help. Thanks.

A: 

I'he resove the problem. It's needed to use namespace for each element and all tags are case sensitive!

Igor