Как зарегистрировать запрос и ответ в формате сообщения мыла при использовании службы мыла - PullRequest
0 голосов
/ 01 ноября 2018

Использование мыльного веб-сервиса.

    Report report = new Report()
    report.setUsername("test");
    report.setPassword("test123");

    System.out.println("Going to make the request .....");
    logger.info("Request :" +report)

    SetReportResponse response =(SetReportResponse) soapConnector.callWebService("http://10.88.12.16/ws/_REQUEST_FEEDBACK/services/Feedback.FeedbackHttpSoap11Endpoint/", report);
    logger.info(response.getReturn());

Как мне зарегистрировать запрос и ответ в формате xml, как именно его отправить клиенту. Прямо как ниже

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.mogk">
   <soapenv:Header/>
   <soapenv:Body>
   .
   .
   .
   .
   .

Предложил в одном посте добавить нижеприведенные записи в свойствах приложения, но это не помогло.

logging.level.org.springframework.web=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.server.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.received=TRACE
logging.level.org.springframework.ws.server.MessageTracing.received=TRACE

Использование Spring Boot 2 и log4j2

Log4j2.xml - включен org.springframework.ws.client.MessageTracing

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Properties>
        <Property name="log-path">D:\Logs/MA</Property>
        >
    </Properties>
    <Appenders>

        <Console name="CONSOLE_APPENDER" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>



        <!-- this file will have all the logging done with log.info others will 
            not come in this file due to usage of the filters -->
        <RollingFile append="true" name="FILE_APPENDER_IFNO"
            fileName="${log-path}/mk-trace.log" filePattern="${log-path}/msa-trace-%d{yyyy-MM-dd}-%i.log">
            <PatternLayout>
                <pattern>%d %p [%t] %m%n</pattern>
            </PatternLayout>

            <Policies>
                <!-- <OnStartupTriggeringPolicy /> -->
                <SizeBasedTriggeringPolicy size="10 MB" />
                <!-- <TimeBasedTriggeringPolicy interval="24" modulate="true" /> -->
            </Policies>

            <Filters>

                <!-- First deny warn, error and fatal messages -->
                <ThresholdFilter level="warn" onMatch="DENY"
                    onMismatch="NEUTRAL" />
                <ThresholdFilter level="error" onMatch="DENY"
                    onMismatch="NEUTRAL" />
                <ThresholdFilter level="fatal" onMatch="DENY"
                    onMismatch="NEUTRAL" />

                <!-- Then accept info, warn, error, fatal and deny debug/trace -->
                <ThresholdFilter level="info" onMatch="ACCEPT"
                    onMismatch="DENY" />
            </Filters>

        </RollingFile>
        <!-- this fill will contain all the errors like log.error -->
        <RollingFile append="false" name="FILE_APPENDER_ERROR"
            fileName="${log-path}/mk-error.log" filePattern="${log-path}/msa-error-%d{yyyy-MM-dd}-%i.log">
            <PatternLayout>
                <pattern>%d %p [%t] %m%n</pattern>
            </PatternLayout>
            <Policies>
                <OnStartupTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="10 MB" />
                <TimeBasedTriggeringPolicy interval="24"
                    modulate="true" />
            </Policies>
        </RollingFile>


    </Appenders>

    <Loggers>
        <Root level="trace">
            <AppenderRef ref="FILE_APPENDER_IFNO" level="INFO" />
            <AppenderRef ref="FILE_APPENDER_ERROR" level="ERROR" />
            <AppenderRef ref="CONSOLE_APPENDER" level="INFO" />
        </Root>

        <logger name="org.springframework.ws.client.MessageTracing">
            <level value="TRACE" />
            <appender-ref ref="console" />
            <appender-ref ref="file" />
        </logger>
        <!-- Spring Webservice XML -->

        <logger name="org.springframework.ws.server.MessageTracing.received">
            <level value="TRACE" />
            <appender-ref ref="console" />
            <appender-ref ref="file" />
        </logger>


        <logger name="org.springframework.ws.server.MessageTracing.sent">
            <level value="TRACE" />
            <appender-ref ref="console" />
            <appender-ref ref="file" />
        </logger>
    </Loggers>
    <!-- TRACE->DEBUG->INFO->WARN->ERROR->FATAL -->

</Configuration>
...