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

Refactor PortUtil.java #11

Open
sfloess opened this issue Mar 22, 2024 · 0 comments
Open

Refactor PortUtil.java #11

sfloess opened this issue Mar 22, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@sfloess
Copy link
Member

sfloess commented Mar 22, 2024

The code is uncharacteristically represents not my best practices: for example temporary variables.

Example:

    <P> P createPortForTargetNamespace(final String targetNamespace, final Class<? extends Service> serviceClass, final SessionContext session) throws SoapException {
        try {
            JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
            factory.setServiceClass(MethodUtil.findMethodsForAnnotationClass(serviceClass, WebEndpoint.class).get(0).getReturnType());

            final P retVal = (P) factory.create();
            final String url = getUrl().computeUrl(serviceClass, session);

            final SOAPElement sessionId = SoapUtil.getSoapFactory().createElement(new QName(targetNamespace, SESSION_ID));
            sessionId.addTextNode(session.sessionId());

            final SOAPElement sessionHeader = SoapUtil.getSoapFactory().createElement(new QName(targetNamespace, SESSION_HEADER));
            sessionHeader.addChildElement(sessionId);

            final List<Header> headers = new ArrayList<Header>();
            final Header soapHeader = new Header(new QName(targetNamespace, SESSION_HEADER), sessionHeader);
            headers.add(soapHeader);

            final Map<String, Object> ctx = ((BindingProvider) retVal).getRequestContext();
            ctx.put(Header.HEADER_LIST, headers);

            SoapUtil.setUrl(retVal, url);

            return retVal;
        } catch(final SOAPException soapException) {
            throw new SoapException(soapException);
        }
    }
@sfloess sfloess added the enhancement New feature or request label Mar 22, 2024
@sfloess sfloess self-assigned this Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant