Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom processor on tag not working #14

Open
xlaussel opened this issue Mar 7, 2017 · 3 comments
Open

Custom processor on tag not working #14

xlaussel opened this issue Mar 7, 2017 · 3 comments

Comments

@xlaussel
Copy link

xlaussel commented Mar 7, 2017

When trying to use a custom processor for a ParentNode (not a text node) it doesn't work: the related fiels stay null.
Here is the code for the matching class:

@XMLObject("//RequestSecurityTokenResponse")
public class TokenWrapper {
    
    public static class RequestedSecurityToken {
        private String xml;
        public RequestedSecurityToken(String lxml) {
            xml=lxml;
        }
        public String getXml() {
            return xml;
        }
    }

    @XMLField(value="RequestedSecurityToken",processor=RequestedSecurityTokenProcessor.class)
    private RequestedSecurityToken requestedSecurityToken;

    public String getToken() {
        return requestedSecurityToken.getXml();
    }

    public static class RequestedSecurityTokenProcessor implements Processor<RequestedSecurityToken> {
        @Override
        public RequestedSecurityToken process(String inputValue) {
            return new RequestedSecurityToken(inputValue);
        }
    }
}

I did look at the code and I think that the bug is in the IseSoapParserImpl at line 401 in the needsParser function: should return true is hasProcessor is true:

	private boolean needsParser(Field fieldToSet) {
		// Is it a text node?
		if (parserMap.containsKey(fieldToSet.getType())) {
			return false;
		}

		// Does it have a processor to deal with it rather than a generic
		// parser?
		if (hasProcessor(fieldToSet)) {
               //Should return true I think
               //or else the cond should be !hasProcessor(fieldToSet)
			return false;
              }

		// Is it a list of text nodes?
		if (List.class.isAssignableFrom(fieldToSet.getType())
				&& parserMap.containsKey(getListItemClass(fieldToSet.getGenericType()))) {
			return false;
		}

		// No to all of the above, .'. it needs a parser
		return true;
	}
@AlexGilleran
Copy link
Owner

Processors are for text nodes or attributes - what are you expecting it to do? I gather you want to have the processor get called with the raw serialized XML for that node?

@xlaussel
Copy link
Author

xlaussel commented Mar 8, 2017

Yes, I want to get the raw xml text for the node RequestedSecurityToken. Is there any way to do that?

@AlexGilleran
Copy link
Owner

Not directly, that's not really how the xml pull parser works - possibly you could parse what's in that node and put it back together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants