kotlin.xml.bind icon indicating copy to clipboard operation
kotlin.xml.bind copied to clipboard

Try with soap envelope

Open mklimek opened this issue 8 years ago • 4 comments

Hello

I try to use your library with simple document:

 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
     <soap:Body>
         <UserAuthenticationResponse>
             <UserAuthenticationResult>
                 <Token>secretTokenFoo4321</Token>
                 <Foo>bla</Foo>
             </UserAuthenticationResult>
             <errorMessage>error</errorMessage>
         </UserAuthenticationResponse>
     </soap:Body>
 </soap:Envelope>

Kotlin class:

 class AuthenticationResponse {
     var token by JXML / "Body" / "UserAuthenticationResponse" / "UserAuthenticationResult" / "Token" / XText
     var unkownElement by JXML / XUnknown
 }

Unfortunately. it doesn't work. I tried with var token by JXML / "soap:Body" / but no success.

If I remove soap: prefix from Body element in xml it starts to work. How to make it work with the namespace soap:Body?

mklimek avatar Sep 13 '16 08:09 mklimek

I solved it by this:

 class AuthenticationResponse {
     var body by JXML / XAnyElement / XSub(Inner::class.java)

     class Inner{
         var token by JXML / "UserAuthenticationResponse" / "UserAuthenticationResult" / "Token" / XText
     }
 }

but I don't think so matching <soap:Body> as XAnyElement is a good idea.

mklimek avatar Sep 13 '16 09:09 mklimek

Currently we have no support for namespaces at all. That's is the luck your workaround works. Looks like a generic issue

jonnyzzz avatar Sep 13 '16 12:09 jonnyzzz

It doesn't work also when element has an attribute:

<UserAuthenticationResponse xmlns:foo="http://foo/foo2/foo3">

I have to replace such an attr with empty string to match class posted above.

mklimek avatar Sep 13 '16 17:09 mklimek

Same bug here. Namespaces are not supported. Are you up to provide a pull request to fix that? That'd be great

Best regards, Eugene Petrenko

On Tue, Sep 13, 2016 at 10:08 AM, Mateusz Klimek [email protected] wrote:

It doesn't work also when element has an attribute:

I have to replace such an attr with empty string to make it work.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jonnyzzz/kotlin.xml.bind/issues/3#issuecomment-246752544, or mute the thread https://github.com/notifications/unsubscribe-auth/AAPpr2k4D8R3lzm-lARlnBv8nt6_OeA0ks5qpth0gaJpZM4J7bHs .

jonnyzzz avatar Sep 13 '16 17:09 jonnyzzz