Ошибка при отправке SOAP-сообщения с использованием Apache CXF - PullRequest
0 голосов
/ 19 июня 2019

Я пытаюсь создать клиент CXF, используя Spring Boot.WSDL включены в мой проект.Источники, созданные с помощью cxf-codegen-plugin.Когда я отправляю запрос, клиент выдает ошибку:

WARN org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {http://bip.bee.kz/SyncChannel/v10/Interfaces}ISyncChannelHttpService#{http://bip.bee.kz/SyncChannel/v10/Interfaces}SendMessage has thrown exception, unwinding now
java.lang.NullPointerException: null
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.createConnection(URLConnectionHTTPConduit.java:112)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.setupConnection(URLConnectionHTTPConduit.java:125)
    at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:505)
    at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:47)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:440)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
    at com.sun.proxy.$Proxy35.sendMessage(Unknown Source)
    at kz.alfabank.egovenforcementagencies.TestClient.main(TestClient.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: javax.xml.ws.soap.SOAPFaultException: Fault string, and possibly fault code, not set
    at org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
    at com.sun.proxy.$Proxy35.sendMessage(Unknown Source)
    at kz.alfabank.egovenforcementagencies.TestClient.main(TestClient.java:112)
    ... 8 more
Caused by: java.lang.NullPointerException
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.createConnection(URLConnectionHTTPConduit.java:112)
    at org.apache.cxf.transport.http.URLConnectionHTTPConduit.setupConnection(URLConnectionHTTPConduit.java:125)
    at org.apache.cxf.transport.http.HTTPConduit.prepare(HTTPConduit.java:505)
    at org.apache.cxf.interceptor.MessageSenderInterceptor.handleMessage(MessageSenderInterceptor.java:47)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:531)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:440)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:355)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
    ... 10 more

Я искал в StackOverflow и сообществах, и они предлагают добавить некоторые заголовки в запрос SOAP, поскольку проблема может быть связана с заголовками запроса.Но в их случае они смогли регистрировать сообщения CXF.Я даже не вижу эти сообщения, потому что перед отправкой выдается ошибка.Может ли кто-нибудь помочь мне найти решение?

Реализация

        try {
//            ISyncChannelHttpService service = new ISyncChannelHttpService(new URL("https://url"));
            ISyncChannelHttpService service = new ISyncChannelHttpService();

            /*
             * Retrieve the port (interface) from the service information
             * to invoke available methods
             */
            ISyncChannel syncChannelHttpPort = service.getSyncChannelHttpPort();

            Client client = ClientProxy.getClient(syncChannelHttpPort);
            client.getInInterceptors().add(new LoggingInInterceptor());
            client.getOutInterceptors().add(new LoggingOutInterceptor());

            Endpoint endpoint = client.getEndpoint();


            /*
             * Preparing SyncSendMessageRequest as parameter to invoke sendMessage method
             * from interface syncChannelHttpPort
             */
            SyncSendMessageRequest syncSendMessageRequest = new SyncSendMessageRequest();


            /*
             * Preparing message info for syncSendMessageRequest
             */
            SyncMessageInfo syncMessageInfo = new SyncMessageInfo();

            SenderInfo sender = new SenderInfo();
            sender.setSenderId(senderId);
            sender.setPassword(senderPassword);

            syncMessageInfo.setMessageId(UUID.randomUUID().toString());
            syncMessageInfo.setMessageId(accountRequestServiceId);
            syncMessageInfo.setMessageDate(getXMLGregorianCalendarFromDate(new Date()));
            syncMessageInfo.setSender(sender);

            /*
             * Preparing message data for syncSendMessageRequest
             */
            RequestData requestData = new RequestData();
            RequestData.Data value = new RequestData.Data();

            R01 r01 = new R01();
            R01RequestMessage r01RequestMessage = new R01RequestMessage();
            r01RequestMessage.setBankID(bankId);
            r01.setItems(r01RequestMessage);
            value.setR01(r01);

            // TODO 2 sign r01
            requestData.setData(value);

            syncSendMessageRequest.setRequestInfo(syncMessageInfo);
            syncSendMessageRequest.setRequestData(requestData);

            /*
             * Sending e-gov's synchronous request message
             * and retrieve e-gov's synchronous response message
             */
            logger.info(">>>>>>>>> sending message...");
            SyncSendMessageResponse syncSendMessageResponse = syncChannelHttpPort.sendMessage(syncSendMessageRequest);

            // TODO 3
            // TODO 4
            // TODO 5
        } catch (SendMessageSendMessageFaultMsg sendMessageSendMessageFaultMsg) {
            sendMessageSendMessageFaultMsg.printStackTrace();
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...