Commit 1c06f8c2 by Assem Malikova

Initial commit

parents
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
plugins {
id 'java'
id 'war'
id 'org.springframework.boot' version '2.7.12'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'kz.arta'
version = '0.0.1-SNAPSHOT'
description = 'nca_iiscon'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation ('org.springframework.boot:spring-boot-starter-web-services'){
//exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
compileOnly 'org.apache.tomcat:tomcat-servlet-api:9.0.37'
// compileOnly 'xerces:xercesImpl:2.8.0'
compileOnly 'org.jboss.resteasy:resteasy-jackson2-provider:3.6.1.Final'
implementation 'org.jboss.resteasy:resteasy-client:3.6.1.Final'
compileOnly 'org.jboss.resteasy:resteasy-multipart-provider:3.6.1.Final'
// jaxb("org.glassfish.jaxb:jaxb-xjc")
annotationProcessor 'org.projectlombok:lombok'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5'
implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.1'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.13'
implementation group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.9.13'
implementation group: 'com.google.guava', name: 'guava', version: '30.1.1-jre'
compileOnly group: 'javax', name: 'javaee-api', version: '8.0'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation group: 'org.jetbrains', name: 'annotations', version: '13.0'
implementation group: 'xerces', name: 'xercesImpl', version: '2.8.0'
implementation 'org.bouncycastle:bcprov-jdk15on:1.68'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.12.6'
implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.12.6'
implementation group: 'org.json', name: 'json', version: '20240303'
implementation 'com.github.seancfoley:ipaddress:5.3.3'
implementation group: 'org.apache.cxf', name: 'cxf-core', version: '3.3.6'
implementation group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version: '3.3.6'
implementation group: 'org.apache.cxf', name: 'cxf-rt-transports-http', version: '3.3.6'
}
\ No newline at end of file
This diff was suppressed by a .gitattributes entry.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header/>
<soap:Body>
<SendMessage xmlns:ns2="http://bip.bee.kz/common/v10/Types" xmlns:ns3="http://bip.bee.kz/SyncChannel/v10/Types"
xmlns="http://bip.bee.kz/SyncChannel/v10/Types">
<request xmlns="">
<requestInfo>
<messageId>12944172-ae77-4e70-8541-d2a968038126</messageId>
<serviceId>nca_iiscon</serviceId>
<messageDate>2025-10-17T11:48:07.530+05:00</messageDate>
<sender>
<senderId>EISDS</senderId>
<password>8zDV~U4OUo</password>
</sender>
</requestInfo>
<requestData>
<data xmlns:s01="http://pki.gov.kz/api/ws/iiscon/wsdl"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="s01:SearchOrderByReferenceNumberRequest">
<s01:referenceNumber>72612562151009</s01:referenceNumber>
</data>
</requestData>
</request>
</SendMessage>
</soap:Body>
</soap:Envelope>
\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
rootProject.name = 'nca_iiscon'
package kz.arta.nca_iiscon;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class NcaIisconApplication {
public static void main(String[] args) {
SpringApplication.run(NcaIisconApplication.class, args);
}
}
package kz.arta.nca_iiscon.controller;
import kz.arta.nca_iiscon.data.forward.ForwardApplication;
import kz.arta.nca_iiscon.data.search.SearchOrderByReferenceNumberRequest;
import kz.arta.nca_iiscon.service.ForwardApplicationNcaService;
import kz.arta.nca_iiscon.service.NcaIISConService;
import kz.arta.nca_iiscon.util.XmlToJsonUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@Slf4j
@ResponseBody
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/service/nca")
public class NcaIISConController {
private final NcaIISConService service;
private final ForwardApplicationNcaService forwardService;
@PostMapping(value = "/iiscon", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Object getSearchOrderByReferenceNumber(@RequestBody SearchOrderByReferenceNumberRequest request
) throws Exception {
log.info("Received request with referenceNumber: {}", request.getReferenceNumber());
// Отправляем запрос и получаем ответ
Object response = service.sendRequest(request);
// Извлекаем data и конвертируем в JSON
String jsonResponse = XmlToJsonUtil.extractDataAsJson(response);
log.info("Converted response to JSON");
return jsonResponse;
}
@PostMapping(value = "/forward", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody Object getInfoOneC(
@RequestBody ForwardApplication request
) throws Exception {
// Отправляем запрос и получаем ответ
Object response = forwardService.sendRequest(request);
// Извлекаем data и конвертируем в JSON
String jsonResponse = XmlToJsonUtil.extractDataAsJson(response);
log.info("Converted response to JSON");
return jsonResponse;
}
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"orgCode", "employee", "systemCode"})
public class CallOrigin {
@XmlElement
private String orgCode;
@XmlElement
private Employee employee;
@XmlElement
private String systemCode;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward;
import kz.arta.nca_iiscon.data.forward.status.ApplicationStatus;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlRootElement(name = "changeApplicationStatus", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"applicationId", "callOrigin", "applicationStatus", "statusDate"})
public class ChangeApplicationStatus {
@XmlElement
private String applicationId;
@XmlElement
private CallOrigin callOrigin;
@XmlElement
private ApplicationStatus applicationStatus;
@XmlElement
private String statusDate;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"lastName", "firstName", "middleName", "position", "iin"})
public class Employee {
@XmlElement
private String lastName;
@XmlElement
private String firstName;
@XmlElement
private String middleName;
@XmlElement
private String position;
@XmlElement
private String iin;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlRootElement(name = "ForwardApplication", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"applicationId", "registerApplication", "updateApplication", "statusHistory"})
public class ForwardApplication {
@XmlElement(name = "applicationId", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String applicationId;
@XmlElement(name = "registerApplication", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private RegisterApplication registerApplication;
@XmlElement(name = "updateApplication", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private UpdateApplication updateApplication;
@XmlElement(name = "statusHistory", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private StatusHistory statusHistory;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward;
import kz.arta.nca_iiscon.data.forward.registration.ApplicationRegistrationData;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlRootElement(name = "registerApplication", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"applicationId", "applicationRegistrationData"})
public class RegisterApplication {
@XmlElement(name = "applicationId")
private String applicationId;
@XmlElement()
private ApplicationRegistrationData applicationRegistrationData;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward;
import lombok.Data;
import javax.xml.bind.annotation.*;
import java.util.List;
@Data
@XmlRootElement(name = "statusHistory", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
@XmlAccessorType(XmlAccessType.FIELD)
public class StatusHistory {
@XmlElement(name = "changeApplicationStatus")
private List<ChangeApplicationStatus> changeApplicationStatus;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward;
import kz.arta.nca_iiscon.data.forward.application.ApplicationData;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlRootElement(name = "updateApplication", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"applicationId", "callOrigin", "applicationData"})
public class UpdateApplication {
@XmlElement(name = "applicationId")
private String applicationId;
@XmlElement()
private CallOrigin callOrigin;
@XmlElement()
private ApplicationData applicationData;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.applicant;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class Applicant {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private Person person;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.applicant;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"dom", "corpus"})
public class Building {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String dom;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String corpus;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.applicant;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"contactType", "contactData", "contactPrefix", "isForNotification"})
public class Contact {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String contactType;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String contactData;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String contactPrefix;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private Boolean isForNotification;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.applicant;
import lombok.Data;
import javax.xml.bind.annotation.*;
import java.util.List;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class Contacts {
@XmlElement(name = "contact", namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private List<Contact> contact;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.applicant;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"docType", "docSer", "docNum", "docDate", "docSource", "expirationDate", "docName"})
public class IdentityDocument {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String docType;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String docSer;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String docNum;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String docDate;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String docSource;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String expirationDate;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String docName;
}
package kz.arta.nca_iiscon.data.forward.applicant;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"areaCode", "districtCode", "countryName", "cityName", "streetName", "building", "apartment"})
public class Location {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String areaCode;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String districtCode;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String countryName;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String cityName;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String streetName;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private Building building;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String apartment;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.applicant;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"iin", "lastName", "firstName", "middleName", "legalLocation",
"actualLocation", "contacts", "identityDocument", "dateOfBirth",
"placeOfBirth", "gender", "isForeigner", "citizenship"})
public class Person {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String iin;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String lastName;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String firstName;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String middleName;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private Location legalLocation;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private Location actualLocation;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private Contacts contacts;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private IdentityDocument identityDocument;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String dateOfBirth;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String placeOfBirth;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String gender;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private Boolean isForeigner;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String citizenship;
}
package kz.arta.nca_iiscon.data.forward.application;
import lombok.Data;
import javax.xml.bind.annotation.*;
import java.util.List;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class ApplicationAttrs {
@XmlElement(name = "attr")
private List<Attr> attr;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.application;
import kz.arta.nca_iiscon.data.forward.applicant.Applicant;
import kz.arta.nca_iiscon.data.forward.document.Documents;
import kz.arta.nca_iiscon.data.forward.payment.Payments;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"applicant", "executorOrgCode", "deliveryOrgCode", "deadline", "cost",
"payments", "copies", "language", "finalDocumentLang", "documents",
"data", "applicationAttrs", "subServiceTypeCode"})
public class ApplicationData {
@XmlElement
private Applicant applicant;
@XmlElement
private String executorOrgCode;
@XmlElement
private String deliveryOrgCode;
@XmlElement
private String deadline;
@XmlElement
private Double cost;
@XmlElement
private Payments payments;
@XmlElement
private Integer copies;
@XmlElement
private String language;
@XmlElement
private String finalDocumentLang;
@XmlElement
private Documents documents;
@XmlElement
private String data;
@XmlElement
private ApplicationAttrs applicationAttrs;
@XmlElement
private String subServiceTypeCode;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.application;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"name", "value"})
public class Attr {
@XmlElement
private String name;
@XmlElement
private String value;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.document;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"documentId", "docTypeCode", "copyType", "docName"})
public class Document {
@XmlElement
private String documentId;
@XmlElement
private String docTypeCode;
@XmlElement
private String copyType;
@XmlElement
private String docName;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.document;
import lombok.Data;
import javax.xml.bind.annotation.*;
import java.util.List;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class Documents {
@XmlElement(name = "document")
private List<Document> document;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.payment;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"paymentId", "cost", "paymentType"})
public class Payment {
@XmlElement
private String paymentId;
@XmlElement
private Double cost;
@XmlElement
private String paymentType;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.payment;
import lombok.Data;
import javax.xml.bind.annotation.*;
import java.util.List;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class Payments {
@XmlElement(name = "payment")
private List<Payment> payment;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.registration;
import kz.arta.nca_iiscon.data.forward.Employee;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"registerId", "registerOrgCode", "serviceTypeCode", "registerDate",
"registerEmployee", "smsCode", "registerMethod"})
public class ApplicationRegistrationData {
@XmlElement
private String registerId;
@XmlElement
private String registerOrgCode;
@XmlElement
private String serviceTypeCode;
@XmlElement
private String registerDate;
@XmlElement
private Employee registerEmployee;
@XmlElement
private String smsCode;
@XmlElement
private String registerMethod;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.status;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
public class ApplicationStatus {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private ExecutionStatus executionStatus;
}
\ No newline at end of file
package kz.arta.nca_iiscon.data.forward.status;
import lombok.Data;
import javax.xml.bind.annotation.*;
@Data
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"appState", "statusInfo", "statusInfoKz"})
public class ExecutionStatus {
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String appState;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String statusInfo;
@XmlElement(namespace = "http://schemas.letograf.kz/iiscon/bus/v1")
private String statusInfoKz;
}
\ No newline at end of file
@XmlSchema(
namespace = "http://pki.gov.kz/api/ws/iiscon/wsdl",
elementFormDefault = XmlNsForm.QUALIFIED,
xmlns = {
@XmlNs(prefix = "s01", namespaceURI = "http://pki.gov.kz/api/ws/iiscon/wsdl"),
@XmlNs(prefix = "xsi", namespaceURI = "http://www.w3.org/2001/XMLSchema-instance")
}
)
package kz.arta.nca_iiscon.data;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlNsForm;
import javax.xml.bind.annotation.XmlSchema;
\ No newline at end of file
package kz.arta.nca_iiscon.data.search;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.xml.bind.annotation.*;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = "SearchOrderByReferenceNumberRequest", namespace = "http://pki.gov.kz/api/ws/iiscon/wsdl")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SearchOrderByReferenceNumberRequest", namespace = "http://pki.gov.kz/api/ws/iiscon/wsdl", propOrder = {
"referenceNumber"
})
public class SearchOrderByReferenceNumberRequest {
@XmlElement(namespace = "http://pki.gov.kz/api/ws/iiscon/wsdl", required = true)
protected String referenceNumber;
}
\ No newline at end of file
package kz.arta.nca_iiscon.service;
import lombok.extern.slf4j.Slf4j;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import java.io.ByteArrayOutputStream;
import java.util.Iterator;
import java.util.Set;
@Slf4j
public class CustomSOAPHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty) {
try {
SOAPMessage soapMessage = context.getMessage();
SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
// Устанавливаем правильный порядок namespace в envelope
envelope.removeNamespaceDeclaration("SOAP-ENV");
envelope.removeNamespaceDeclaration("wsu");
envelope.removeNamespaceDeclaration("xsd");
// Добавляем в правильном порядке
envelope.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema");
envelope.addNamespaceDeclaration("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
envelope.addNamespaceDeclaration("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
// Убеждаемся, что есть Header
SOAPHeader header = envelope.getHeader();
if (header == null) {
envelope.addHeader();
}
SOAPBody body = envelope.getBody();
// Находим элемент SendMessage
SOAPElement sendMessage = (SOAPElement) body.getChildElements(
new QName("http://bip.bee.kz/SyncChannel/v10/Types", "SendMessage")
).next();
if (sendMessage != null) {
// Удаляем лишние namespace из SendMessage
sendMessage.removeNamespaceDeclaration("ns4");
sendMessage.removeNamespaceDeclaration("ns5");
sendMessage.removeNamespaceDeclaration("s01");
sendMessage.removeNamespaceDeclaration("xsi");
// SendMessage должен остаться без префикса
sendMessage.setPrefix("");
// Находим request
SOAPElement request = (SOAPElement) sendMessage.getChildElements(
new QName("", "request")
).next();
if (request != null) {
request.setAttribute("xmlns", "");
// Обрабатываем data элемент
processDataElement(request);
}
}
soapMessage.saveChanges();
// Логируем финальное сообщение
if (log.isInfoEnabled()) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
soapMessage.writeTo(out);
log.info("Outbound SOAP Message:\n{}", out.toString("UTF-8"));
}
} catch (Exception e) {
log.error("Error in SOAP Handler", e);
}
}
return true;
}
private void processDataElement(SOAPElement parent) throws SOAPException {
// Рекурсивно проходим по всем элементам
Iterator iterator = parent.getChildElements();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof SOAPElement) {
SOAPElement element = (SOAPElement) obj;
// Если это data элемент
if ("data".equals(element.getLocalName())) {
// Убираем префикс s01 у data
element.setPrefix("");
// Добавляем xmlns:xsi и xmlns:s01
element.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance");
element.addNamespaceDeclaration("s01", "http://pki.gov.kz/api/ws/iiscon/wsdl");
// Устанавливаем xsi:type
element.setAttributeNS(
"http://www.w3.org/2001/XMLSchema-instance",
"xsi:type",
"s01:SearchOrderByReferenceNumberRequest"
);
}
// Меняем префикс на s01 для всех дочерних элементов из namespace http://pki.gov.kz/api/ws/iiscon/wsdl
String namespaceURI = element.getNamespaceURI();
if ("http://pki.gov.kz/api/ws/iiscon/wsdl".equals(namespaceURI)) {
element.setPrefix("s01");
}
// Рекурсивно обрабатываем детей
processDataElement(element);
}
}
}
@Override
public boolean handleFault(SOAPMessageContext context) {
return true;
}
@Override
public void close(MessageContext context) {
}
@Override
public Set<QName> getHeaders() {
return null;
}
}
\ No newline at end of file
package kz.arta.nca_iiscon.service;
import kz.arta.nca_iiscon.data.forward.ForwardApplication;
import kz.arta.nca_iiscon.data.search.SearchOrderByReferenceNumberRequest;
import kz.arta.nca_iiscon.shep.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.xml.bind.*;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Slf4j
@Service
public class ForwardApplicationNcaService {
@Value("${login}")
private String senderIdSHEP;
@Value("${password}")
private String senderPassSHEP;
@Value("${forward_service_id}")
private String serviceIdSHEP;
@Value("${service_url}")
private String urlSHEP;
public Object sendRequest(ForwardApplication request) throws Exception {
try {
log.info("Initiating SHEP request to URL: {}", urlSHEP);
// Prepare the SHEP request
SyncSendMessageRequest shepRequest = prepareShepRequest(request);
logRequest(shepRequest);
// Get and configure the port
ISyncChannel port = getConfiguredPort();
// Send the request and process response
SyncSendMessageResponse response = port.sendMessage(shepRequest);
log.info("Received SHEP response: {}", response);
return response;
} catch (SendMessageSendMessageFaultMsg e) {
String errorResponse = handleFaultMessage(e.getFaultInfo());
log.error("SHEP request failed: {}", errorResponse);
return errorResponse;
} catch (Exception e) {
log.error("Unexpected error during SHEP request", e);
throw e;
}
}
private SyncSendMessageRequest prepareShepRequest(ForwardApplication request)
throws DatatypeConfigurationException {
SyncSendMessageRequest shepRequest = new SyncSendMessageRequest();
SyncMessageInfo info = new SyncMessageInfo();
// Set sender information
SenderInfo sender = new SenderInfo();
sender.setPassword(senderPassSHEP);
sender.setSenderId(senderIdSHEP);
// Configure message info
info.setSender(sender);
info.setMessageId(UUID.randomUUID().toString());
info.setServiceId(serviceIdSHEP);
info.setMessageDate(new Date());
shepRequest.setRequestInfo(info);
shepRequest.setRequestData(new RequestData());
// Оборачиваем в JAXBElement с пустым namespace для элемента data
QName qname = new QName("", "data");
JAXBElement<ForwardApplication> jaxbElement =
new JAXBElement<>(qname, ForwardApplication.class, request);
shepRequest.getRequestData().setData(jaxbElement);
return shepRequest;
}
private ISyncChannel getConfiguredPort() {
ISyncChannel port = getPort();
BindingProvider bp = (BindingProvider) port;
// Configure endpoint address
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, urlSHEP);
// Add handlers
List<Handler> handlers = new ArrayList<>(2);
handlers.add(new ForwardSOAPHandler()); // Добавляем кастомный handler первым
handlers.add(new WriteHandler());
bp.getBinding().setHandlerChain(handlers);
return port;
}
private void logRequest(SyncSendMessageRequest request) {
if (log.isInfoEnabled()) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(
SyncSendMessageRequest.class,
SearchOrderByReferenceNumberRequest.class,
ForwardApplication.class
);
StringWriter sw = new StringWriter();
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(request, sw);
log.info("SHEP SearchOrderByReferenceNumberRequest: {}", sw.toString());
} catch (JAXBException e) {
log.warn("Failed to log request", e);
}
}
}
private String handleFaultMessage(Object e) {
StringWriter sw = new StringWriter();
JAXB.marshal(e, sw);
return sw.toString();
}
private ISyncChannel getPort() {
ISyncChannel port;
QName portQName = new QName("http://bip.bee.kz/SyncChannel/v10/Interfaces", "ISyncChannel");
javax.xml.ws.Service service = javax.xml.ws.Service.create(portQName);
port = service.getPort(ISyncChannel.class);
return port;
}
}
package kz.arta.nca_iiscon.service;
import lombok.extern.slf4j.Slf4j;
import javax.xml.namespace.QName;
import javax.xml.soap.*;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import java.io.ByteArrayOutputStream;
import java.util.Iterator;
import java.util.Set;
@Slf4j
public class ForwardSOAPHandler implements SOAPHandler<SOAPMessageContext> {
private static final String IISCON_NAMESPACE = "http://schemas.letograf.kz/iiscon/bus/v1";
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty) {
try {
SOAPMessage soapMessage = context.getMessage();
SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
// Устанавливаем правильный порядок namespace в envelope
envelope.removeNamespaceDeclaration("SOAP-ENV");
envelope.removeNamespaceDeclaration("wsu");
envelope.removeNamespaceDeclaration("xsd");
// Добавляем в правильном порядке
envelope.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema");
envelope.addNamespaceDeclaration("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
envelope.addNamespaceDeclaration("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
// Убеждаемся, что есть Header
SOAPHeader header = envelope.getHeader();
if (header == null) {
envelope.addHeader();
}
SOAPBody body = envelope.getBody();
// Находим элемент SendMessage
SOAPElement sendMessage = (SOAPElement) body.getChildElements(
new QName("http://bip.bee.kz/SyncChannel/v10/Types", "SendMessage")
).next();
if (sendMessage != null) {
// Удаляем лишние namespace из SendMessage
sendMessage.removeNamespaceDeclaration("ns4");
sendMessage.removeNamespaceDeclaration("ns5");
sendMessage.removeNamespaceDeclaration("s01");
sendMessage.removeNamespaceDeclaration("xsi");
// SendMessage должен остаться без префикса
sendMessage.setPrefix("");
// Находим request
SOAPElement request = (SOAPElement) sendMessage.getChildElements(
new QName("", "request")
).next();
if (request != null) {
request.setAttribute("xmlns", "");
// Обрабатываем data элемент
processDataElement(request);
}
}
soapMessage.saveChanges();
// Логируем финальное сообщение
if (log.isInfoEnabled()) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
soapMessage.writeTo(out);
log.info("Outbound SOAP Message:\n{}", out.toString("UTF-8"));
}
} catch (Exception e) {
log.error("Error in SOAP Handler", e);
}
}
return true;
}
private void processDataElement(SOAPElement parent) throws SOAPException {
Iterator iterator = parent.getChildElements();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof SOAPElement) {
SOAPElement element = (SOAPElement) obj;
String localName = element.getLocalName();
// Если это data элемент
if ("data".equals(localName)) {
// Убираем префикс у data
element.setPrefix("");
// Добавляем xmlns:xsi и xmlns:s01
element.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance");
element.addNamespaceDeclaration("s01", IISCON_NAMESPACE);
// Устанавливаем xsi:type
element.setAttributeNS(
"http://www.w3.org/2001/XMLSchema-instance",
"xsi:type",
"s01:ForwardApplication"
);
// Обрабатываем дочерние элементы data
processForwardApplicationChildren(element);
}
// Рекурсивно обрабатываем детей
processDataElement(element);
}
}
}
private void processForwardApplicationChildren(SOAPElement dataElement) throws SOAPException {
Iterator iterator = dataElement.getChildElements();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof SOAPElement) {
SOAPElement element = (SOAPElement) obj;
String localName = element.getLocalName();
String namespaceURI = element.getNamespaceURI();
// Определяем, какие элементы должны иметь префикс s01:
if (shouldHaveS01Prefix(localName)) {
// Устанавливаем префикс s01: для этих элементов
if (IISCON_NAMESPACE.equals(namespaceURI)) {
element.setPrefix("s01");
}
// Обрабатываем statusHistory отдельно
if ("statusHistory".equals(localName)) {
processStatusHistory(element);
}
} else {
// Для registerApplication, updateApplication убираем префикс
element.setPrefix("");
// Их дочерние элементы НЕ должны иметь префикс
removePrefixFromChildren(element);
}
}
}
}
private void processStatusHistory(SOAPElement statusHistoryElement) throws SOAPException {
Iterator iterator = statusHistoryElement.getChildElements();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof SOAPElement) {
SOAPElement element = (SOAPElement) obj;
String localName = element.getLocalName();
// Если это changeApplicationStatus
if ("changeApplicationStatus".equals(localName)) {
// Убираем все префиксы у changeApplicationStatus и его детей
element.setPrefix("");
removePrefixFromChildren(element);
}
}
}
}
private void removePrefixFromChildren(SOAPElement parent) throws SOAPException {
Iterator iterator = parent.getChildElements();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof SOAPElement) {
SOAPElement element = (SOAPElement) obj;
// Убираем префикс
element.setPrefix("");
// Рекурсивно обрабатываем детей
removePrefixFromChildren(element);
}
}
}
/**
* Определяет, какие элементы должны иметь префикс s01:
*/
private boolean shouldHaveS01Prefix(String localName) {
return "applicationId".equals(localName) ||
"statusHistory".equals(localName);
}
@Override
public boolean handleFault(SOAPMessageContext context) {
return true;
}
@Override
public void close(MessageContext context) {
}
@Override
public Set<QName> getHeaders() {
return null;
}
}
package kz.arta.nca_iiscon.service;
import kz.arta.nca_iiscon.data.search.SearchOrderByReferenceNumberRequest;
import kz.arta.nca_iiscon.shep.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.xml.bind.*;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.Handler;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
@Slf4j
@Service
public class NcaIISConService {
@Value("${login}")
private String senderIdSHEP;
@Value("${password}")
private String senderPassSHEP;
@Value("${service_id}")
private String serviceIdSHEP;
@Value("${service_url}")
private String urlSHEP;
public Object sendRequest(SearchOrderByReferenceNumberRequest request) throws Exception {
try {
log.info("Initiating SHEP request to URL: {}", urlSHEP);
// Prepare the SHEP request
SyncSendMessageRequest shepRequest = prepareShepRequest(request);
logRequest(shepRequest);
// Get and configure the port
ISyncChannel port = getConfiguredPort();
// Send the request and process response
SyncSendMessageResponse response = port.sendMessage(shepRequest);
log.info("Received SHEP response: {}", response);
return response;
} catch (SendMessageSendMessageFaultMsg e) {
String errorResponse = handleFaultMessage(e.getFaultInfo());
log.error("SHEP request failed: {}", errorResponse);
return errorResponse;
} catch (Exception e) {
log.error("Unexpected error during SHEP request", e);
throw e;
}
}
private SyncSendMessageRequest prepareShepRequest(SearchOrderByReferenceNumberRequest request)
throws DatatypeConfigurationException {
SyncSendMessageRequest shepRequest = new SyncSendMessageRequest();
SyncMessageInfo info = new SyncMessageInfo();
// Set sender information
SenderInfo sender = new SenderInfo();
sender.setPassword(senderPassSHEP);
sender.setSenderId(senderIdSHEP);
// Configure message info
info.setSender(sender);
info.setMessageId(UUID.randomUUID().toString());
info.setServiceId(serviceIdSHEP);
info.setMessageDate(new Date());
shepRequest.setRequestInfo(info);
shepRequest.setRequestData(new RequestData());
// Оборачиваем в JAXBElement с пустым namespace для элемента data
QName qname = new QName("", "data");
JAXBElement<SearchOrderByReferenceNumberRequest> jaxbElement =
new JAXBElement<>(qname, SearchOrderByReferenceNumberRequest.class, request);
shepRequest.getRequestData().setData(jaxbElement);
return shepRequest;
}
private ISyncChannel getConfiguredPort() {
ISyncChannel port = getPort();
BindingProvider bp = (BindingProvider) port;
// Configure endpoint address
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, urlSHEP);
// Add handlers
List<Handler> handlers = new ArrayList<>(2);
handlers.add(new CustomSOAPHandler()); // Добавляем кастомный handler первым
handlers.add(new WriteHandler());
bp.getBinding().setHandlerChain(handlers);
return port;
}
private void logRequest(SyncSendMessageRequest request) {
if (log.isInfoEnabled()) {
try {
JAXBContext jaxbContext = JAXBContext.newInstance(
SyncSendMessageRequest.class,
SearchOrderByReferenceNumberRequest.class
);
StringWriter sw = new StringWriter();
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(request, sw);
log.info("SHEP SearchOrderByReferenceNumberRequest: {}", sw.toString());
} catch (JAXBException e) {
log.warn("Failed to log request", e);
}
}
}
private String handleFaultMessage(Object e) {
StringWriter sw = new StringWriter();
JAXB.marshal(e, sw);
return sw.toString();
}
private ISyncChannel getPort() {
ISyncChannel port;
QName portQName = new QName("http://bip.bee.kz/SyncChannel/v10/Interfaces", "ISyncChannel");
javax.xml.ws.Service service = javax.xml.ws.Service.create(portQName);
port = service.getPort(ISyncChannel.class);
return port;
}
}
\ No newline at end of file
package kz.arta.nca_iiscon.service;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
import java.io.File;
import java.io.FileOutputStream;
import java.util.Set;
public class WriteHandler implements SOAPHandler<SOAPMessageContext> {
@Override
public Set<QName> getHeaders() {
return null;
}
@Override
public boolean handleMessage(SOAPMessageContext context) {
SOAPMessage msg = context.getMessage();
String filename="response.xml";
Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty){
filename="request.xml";
}
try {
FileOutputStream fileOutputStream =new FileOutputStream(new File(filename));
msg.writeTo(fileOutputStream);
} catch (Exception e) {
e.printStackTrace();
}
return true;
}
@Override
public boolean handleFault(SOAPMessageContext context) {
return false;
}
@Override
public void close(MessageContext context) {
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Java class for ErrorInfo complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ErrorInfo">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="errorCode" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="errorMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="errorData" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="errorDate" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="subError" type="{http://bip.bee.kz/common/v10/Types}ErrorInfo" minOccurs="0"/>
* &lt;element name="sessionId" type="{http://bip.bee.kz/common/v10/Types}guid" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ErrorInfo", propOrder = {
"errorCode",
"errorMessage",
"errorData",
"errorDate",
"subError",
"sessionId"
})
public class ErrorInfo {
@XmlElement(required = true)
protected String errorCode;
@XmlElement(required = true)
protected String errorMessage;
protected String errorData;
@XmlElement(required = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar errorDate;
protected ErrorInfo subError;
protected String sessionId;
/**
* Gets the value of the errorCode property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getErrorCode() {
return errorCode;
}
/**
* Sets the value of the errorCode property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setErrorCode(String value) {
this.errorCode = value;
}
/**
* Gets the value of the errorMessage property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getErrorMessage() {
return errorMessage;
}
/**
* Sets the value of the errorMessage property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setErrorMessage(String value) {
this.errorMessage = value;
}
/**
* Gets the value of the errorData property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getErrorData() {
return errorData;
}
/**
* Sets the value of the errorData property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setErrorData(String value) {
this.errorData = value;
}
/**
* Gets the value of the errorDate property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getErrorDate() {
return errorDate;
}
/**
* Sets the value of the errorDate property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setErrorDate(XMLGregorianCalendar value) {
this.errorDate = value;
}
/**
* Gets the value of the subError property.
*
* @return
* possible object is
* {@link ErrorInfo }
*
*/
public ErrorInfo getSubError() {
return subError;
}
/**
* Sets the value of the subError property.
*
* @param value
* allowed object is
* {@link ErrorInfo }
*
*/
public void setSubError(ErrorInfo value) {
this.subError = value;
}
/**
* Gets the value of the sessionId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getSessionId() {
return sessionId;
}
/**
* Sets the value of the sessionId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSessionId(String value) {
this.sessionId = value;
}
}
package kz.arta.nca_iiscon.shep;
import kz.arta.nca_iiscon.data.forward.ForwardApplication;
import kz.arta.nca_iiscon.data.search.SearchOrderByReferenceNumberRequest;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
@WebService(name = "ISyncChannel", targetNamespace = "http://bip.bee.kz/SyncChannel/v10/Interfaces")
@XmlSeeAlso({
ObjectFactory.class, SearchOrderByReferenceNumberRequest.class, ForwardApplication.class})
public interface ISyncChannel {
/**
*
* @param request
* @return
* returns shep.SyncSendMessageResponse
* @throws SendMessageSendMessageFaultMsg
*/
@WebMethod(operationName = "SendMessage")
@WebResult(name = "response", targetNamespace = "")
@RequestWrapper(localName = "SendMessage", targetNamespace = "http://bip.bee.kz/SyncChannel/v10/Types", className = "shep.SendMessage")
@ResponseWrapper(localName = "SendMessageResponse", targetNamespace = "http://bip.bee.kz/SyncChannel/v10/Types", className = "shep.SendMessageResponse")
public SyncSendMessageResponse sendMessage(
@WebParam(name = "request", targetNamespace = "")
SyncSendMessageRequest request)
throws SendMessageSendMessageFaultMsg
;
}
package kz.arta.nca_iiscon.shep;
import javax.xml.namespace.QName;
import javax.xml.ws.*;
import java.net.MalformedURLException;
import java.net.URL;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebServiceClient(name = "ISyncChannelHttpService", targetNamespace = "http://bip.bee.kz/SyncChannel/v10/Interfaces/Binding2", wsdlLocation = "/wsdl/SyncChannel/v10/Interfaces/SyncChannelHttp_Service.wsdl")
public class ISyncChannelHttpService
extends Service
{
private final static URL ISYNCCHANNELHTTPSERVICE_WSDL_LOCATION;
private final static WebServiceException ISYNCCHANNELHTTPSERVICE_EXCEPTION;
private final static QName ISYNCCHANNELHTTPSERVICE_QNAME = new QName("http://bip.bee.kz/SyncChannel/v10/Interfaces/Binding2", "ISyncChannelHttpService");
static {
URL url = null;
WebServiceException e = null;
try {
url = new URL("/wsdl/SyncChannel/v10/Interfaces/SyncChannelHttp_Service.wsdl");
} catch (MalformedURLException ex) {
e = new WebServiceException(ex);
}
ISYNCCHANNELHTTPSERVICE_WSDL_LOCATION = url;
ISYNCCHANNELHTTPSERVICE_EXCEPTION = e;
}
public ISyncChannelHttpService() {
super(__getWsdlLocation(), ISYNCCHANNELHTTPSERVICE_QNAME);
}
public ISyncChannelHttpService(WebServiceFeature... features) {
super(__getWsdlLocation(), ISYNCCHANNELHTTPSERVICE_QNAME, features);
}
public ISyncChannelHttpService(URL wsdlLocation) {
super(wsdlLocation, ISYNCCHANNELHTTPSERVICE_QNAME);
}
public ISyncChannelHttpService(URL wsdlLocation, WebServiceFeature... features) {
super(wsdlLocation, ISYNCCHANNELHTTPSERVICE_QNAME, features);
}
public ISyncChannelHttpService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public ISyncChannelHttpService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
super(wsdlLocation, serviceName, features);
}
/**
*
* @return
* returns ISyncChannel
*/
@WebEndpoint(name = "SyncChannelHttpPort")
public ISyncChannel getSyncChannelHttpPort() {
return super.getPort(new QName("http://bip.bee.kz/SyncChannel/v10/Interfaces/Binding2", "SyncChannelHttpPort"), ISyncChannel.class);
}
/**
*
* @param features
* A list of {@link WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values.
* @return
* returns ISyncChannel
*/
@WebEndpoint(name = "SyncChannelHttpPort")
public ISyncChannel getSyncChannelHttpPort(WebServiceFeature... features) {
return super.getPort(new QName("http://bip.bee.kz/SyncChannel/v10/Interfaces/Binding2", "SyncChannelHttpPort"), ISyncChannel.class, features);
}
private static URL __getWsdlLocation() {
if (ISYNCCHANNELHTTPSERVICE_EXCEPTION!= null) {
throw ISYNCCHANNELHTTPSERVICE_EXCEPTION;
}
return ISYNCCHANNELHTTPSERVICE_WSDL_LOCATION;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the shep package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _SendMessageFault1SendMessageFault_QNAME = new QName("http://bip.bee.kz/SyncChannel/v10/Types", "SendMessageFault1_SendMessageFault");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: shep
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link SendMessageResponse }
*
*/
public SendMessageResponse createSendMessageResponse() {
return new SendMessageResponse();
}
/**
* Create an instance of {@link SyncSendMessageResponse }
*
*/
public SyncSendMessageResponse createSyncSendMessageResponse() {
return new SyncSendMessageResponse();
}
/**
* Create an instance of {@link ErrorInfo }
*
*/
public ErrorInfo createErrorInfo() {
return new ErrorInfo();
}
/**
* Create an instance of {@link SendMessage }
*
*/
public SendMessage createSendMessage() {
return new SendMessage();
}
/**
* Create an instance of {@link SyncSendMessageRequest }
*
*/
public SyncSendMessageRequest createSyncSendMessageRequest() {
return new SyncSendMessageRequest();
}
/**
* Create an instance of {@link SyncMessageInfoResponse }
*
*/
public SyncMessageInfoResponse createSyncMessageInfoResponse() {
return new SyncMessageInfoResponse();
}
/**
* Create an instance of {@link SyncMessageInfo }
*
*/
public SyncMessageInfo createSyncMessageInfo() {
return new SyncMessageInfo();
}
/**
* Create an instance of {@link SenderInfo }
*
*/
public SenderInfo createSenderInfo() {
return new SenderInfo();
}
/**
* Create an instance of {@link StatusInfo }
*
*/
public StatusInfo createStatusInfo() {
return new StatusInfo();
}
/**
* Create an instance of {@link Property }
*
*/
public Property createProperty() {
return new Property();
}
/**
* Create an instance of {@link ResponseData }
*
*/
public ResponseData createResponseData() {
return new ResponseData();
}
/**
* Create an instance of {@link RequestData }
*
*/
public RequestData createRequestData() {
return new RequestData();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link ErrorInfo }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://bip.bee.kz/SyncChannel/v10/Types", name = "SendMessageFault1_SendMessageFault")
public JAXBElement<ErrorInfo> createSendMessageFault1SendMessageFault(ErrorInfo value) {
return new JAXBElement<ErrorInfo>(_SendMessageFault1SendMessageFault_QNAME, ErrorInfo.class, null, value);
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
*
*
* <p>Java class for Property complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Property">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="key">
* &lt;simpleType>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;minLength value="0"/>
* &lt;maxLength value="30"/>
* &lt;/restriction>
* &lt;/simpleType>
* &lt;/element>
* &lt;element name="value">
* &lt;simpleType>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;maxLength value="500"/>
* &lt;minLength value="0"/>
* &lt;/restriction>
* &lt;/simpleType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Property", propOrder = {
"key",
"value"
})
public class Property {
@XmlElement(required = true)
protected String key;
@XmlElement(required = true)
protected String value;
/**
* Gets the value of the key property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getKey() {
return key;
}
/**
* Sets the value of the key property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setKey(String value) {
this.key = value;
}
/**
* Gets the value of the value property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getValue() {
return value;
}
/**
* Sets the value of the value property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setValue(String value) {
this.value = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RequestData", namespace = "http://bip.bee.kz/SyncChannel/v10/Types/Request")
public class RequestData {
@XmlAnyElement(lax = true)
protected Object data;
/**
* Gets the value of the data property.
*
* @return
* possible object is
* {@link Object }
*
*/
public Object getData() {
return data;
}
/**
* Sets the value of the data property.
*
* @param value
* allowed object is
* {@link Object }
*
*/
public void setData(Object value) {
this.data = value;
}
}
\ No newline at end of file
package kz.arta.nca_iiscon.shep;
import lombok.ToString;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ResponseData complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ResponseData">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="data" type="{http://www.w3.org/2001/XMLSchema}anyType" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@ToString
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResponseData", namespace = "http://bip.bee.kz/SyncChannel/v10/Types/Response", propOrder = {
"data"
}) public class ResponseData {
protected Object data;
/**
* Gets the value of the data property.
*
* @return
* possible object is
* {@link Object }
*
*/
public Object getData() {
return data;
}
/**
* Sets the value of the data property.
*
* @param value
* allowed object is
* {@link Object }
*
*/
public void setData(Object value) {
this.data = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="request" type="{http://bip.bee.kz/SyncChannel/v10/Types/Request}SyncSendMessageRequest"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"request"
})
@XmlRootElement(name = "SendMessage", namespace = "http://bip.bee.kz/SyncChannel/v10/Types")
public class SendMessage {
@XmlElement(required = true, nillable = true)
protected SyncSendMessageRequest request;
/**
* Gets the value of the request property.
*
* @return
* possible object is
* {@link SyncSendMessageRequest }
*
*/
public SyncSendMessageRequest getRequest() {
return request;
}
/**
* Sets the value of the request property.
*
* @param value
* allowed object is
* {@link SyncSendMessageRequest }
*
*/
public void setRequest(SyncSendMessageRequest value) {
this.request = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="response" type="{http://bip.bee.kz/SyncChannel/v10/Types/Response}SyncSendMessageResponse"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"response"
})
@XmlRootElement(name = "SendMessageResponse", namespace = "http://bip.bee.kz/SyncChannel/v10/Types")
public class SendMessageResponse {
@XmlElement(required = true, nillable = true)
protected SyncSendMessageResponse response;
/**
* Gets the value of the response property.
*
* @return
* possible object is
* {@link SyncSendMessageResponse }
*
*/
public SyncSendMessageResponse getResponse() {
return response;
}
/**
* Sets the value of the response property.
*
* @param value
* allowed object is
* {@link SyncSendMessageResponse }
*
*/
public void setResponse(SyncSendMessageResponse value) {
this.response = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.ws.WebFault;
/**
* This class was generated by the JAX-WS RI.
* JAX-WS RI 2.2.9-b130926.1035
* Generated source version: 2.2
*
*/
@WebFault(name = "SendMessageFault1_SendMessageFault", targetNamespace = "http://bip.bee.kz/SyncChannel/v10/Types")
public class SendMessageSendMessageFaultMsg
extends Exception
{
/**
* Java type that goes as soapenv:Fault detail element.
*
*/
private ErrorInfo faultInfo;
/**
*
* @param faultInfo
* @param message
*/
public SendMessageSendMessageFaultMsg(String message, ErrorInfo faultInfo) {
super(message);
this.faultInfo = faultInfo;
}
/**
*
* @param faultInfo
* @param cause
* @param message
*/
public SendMessageSendMessageFaultMsg(String message, ErrorInfo faultInfo, Throwable cause) {
super(message, cause);
this.faultInfo = faultInfo;
}
/**
*
* @return
* returns fault bean: shep.ErrorInfo
*/
public ErrorInfo getFaultInfo() {
return faultInfo;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* ��������� ������ ���������� �� �����������
*
* <p>Java class for SenderInfo complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="SenderInfo">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="senderId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="password" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SenderInfo", propOrder = {
"senderId",
"password"
})
public class SenderInfo {
@XmlElement(required = true)
protected String senderId;
protected String password;
/**
* Gets the value of the senderId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getSenderId() {
return senderId;
}
/**
* Sets the value of the senderId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSenderId(String value) {
this.senderId = value;
}
/**
* Gets the value of the password property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getPassword() {
return password;
}
/**
* Sets the value of the password property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setPassword(String value) {
this.password = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* ������
*
* <p>Java class for StatusInfo complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="StatusInfo">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="code" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="message">
* &lt;simpleType>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;maxLength value="250"/>
* &lt;/restriction>
* &lt;/simpleType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "StatusInfo", propOrder = {
"code",
"message"
})
public class StatusInfo {
@XmlElement(required = true)
protected String code;
@XmlElement(required = true)
protected String message;
/**
* Gets the value of the code property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCode() {
return code;
}
/**
* Sets the value of the code property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCode(String value) {
this.code = value;
}
/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}
/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p>Java class for SyncMessageInfo complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="SyncMessageInfo">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="correlationId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="serviceId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="messageDate" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="routeId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="sender" type="{http://bip.bee.kz/common/v10/Types}SenderInfo"/>
* &lt;element name="properties" type="{http://bip.bee.kz/common/v10/Types}Property" maxOccurs="unbounded" minOccurs="0"/>
* &lt;element name="sessionId" type="{http://bip.bee.kz/common/v10/Types}guid" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SyncMessageInfo", namespace = "http://bip.bee.kz/SyncChannel/v10/Types", propOrder = {
"messageId",
"correlationId",
"serviceId",
"messageDate",
"routeId",
"sender",
"properties",
"sessionId"
})
public class SyncMessageInfo {
@XmlElement(required = true)
protected String messageId;
protected String correlationId;
@XmlElement(required = true)
protected String serviceId;
@XmlElement(required = true)
@XmlSchemaType(name = "dateTime")
protected Date messageDate;
protected String routeId;
@XmlElement(required = true)
protected SenderInfo sender;
protected List<Property> properties;
protected String sessionId;
/**
* Gets the value of the messageId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessageId() {
return messageId;
}
/**
* Sets the value of the messageId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessageId(String value) {
this.messageId = value;
}
/**
* Gets the value of the correlationId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCorrelationId() {
return correlationId;
}
/**
* Sets the value of the correlationId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCorrelationId(String value) {
this.correlationId = value;
}
/**
* Gets the value of the serviceId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getServiceId() {
return serviceId;
}
/**
* Sets the value of the serviceId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setServiceId(String value) {
this.serviceId = value;
}
public Date getMessageDate() {
return messageDate;
}
public void setMessageDate(Date messageDate) {
this.messageDate = messageDate;
}
/**
* Gets the value of the routeId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRouteId() {
return routeId;
}
/**
* Sets the value of the routeId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRouteId(String value) {
this.routeId = value;
}
/**
* Gets the value of the sender property.
*
* @return
* possible object is
* {@link SenderInfo }
*
*/
public SenderInfo getSender() {
return sender;
}
/**
* Sets the value of the sender property.
*
* @param value
* allowed object is
* {@link SenderInfo }
*
*/
public void setSender(SenderInfo value) {
this.sender = value;
}
/**
* Gets the value of the properties property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the properties property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getProperties().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Property }
*
*
*/
public List<Property> getProperties() {
if (properties == null) {
properties = new ArrayList<Property>();
}
return this.properties;
}
/**
* Gets the value of the sessionId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getSessionId() {
return sessionId;
}
/**
* Sets the value of the sessionId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSessionId(String value) {
this.sessionId = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
import java.util.Date;
/**
* <p>Java class for SyncMessageInfoResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="SyncMessageInfoResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="messageId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="correlationId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="responseDate" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="status" type="{http://bip.bee.kz/common/v10/Types}StatusInfo"/>
* &lt;element name="sessionId" type="{http://bip.bee.kz/common/v10/Types}guid" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SyncMessageInfoResponse", namespace = "http://bip.bee.kz/SyncChannel/v10/Types", propOrder = {
"messageId",
"correlationId",
"responseDate",
"status",
"sessionId"
})
public class SyncMessageInfoResponse {
@XmlElement(required = true)
protected String messageId;
protected String correlationId;
@XmlElement(required = true)
@XmlSchemaType(name = "dateTime")
protected Date responseDate;
@XmlElement(required = true)
protected StatusInfo status;
protected String sessionId;
/**
* Gets the value of the messageId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessageId() {
return messageId;
}
/**
* Sets the value of the messageId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessageId(String value) {
this.messageId = value;
}
/**
* Gets the value of the correlationId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCorrelationId() {
return correlationId;
}
/**
* Sets the value of the correlationId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCorrelationId(String value) {
this.correlationId = value;
}
public Date getResponseDate() {
return responseDate;
}
public void setResponseDate(Date responseDate) {
this.responseDate = responseDate;
}
/**
* Gets the value of the status property.
*
* @return
* possible object is
* {@link StatusInfo }
*
*/
public StatusInfo getStatus() {
return status;
}
/**
* Sets the value of the status property.
*
* @param value
* allowed object is
* {@link StatusInfo }
*
*/
public void setStatus(StatusInfo value) {
this.status = value;
}
/**
* Gets the value of the sessionId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getSessionId() {
return sessionId;
}
/**
* Sets the value of the sessionId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSessionId(String value) {
this.sessionId = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
/**
*
* <p>Java class for SyncSendMessageRequest complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="SyncSendMessageRequest">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="requestInfo" type="{http://bip.bee.kz/SyncChannel/v10/Types}SyncMessageInfo"/>
* &lt;element name="requestData" type="{http://bip.bee.kz/SyncChannel/v10/Types/Request}RequestData"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SyncSendMessageRequest", namespace = "http://bip.bee.kz/SyncChannel/v10/Types/Request", propOrder = {
"requestInfo",
"requestData"
})
@XmlRootElement
@XmlSeeAlso({})
public class SyncSendMessageRequest {
@XmlElement(required = true)
protected SyncMessageInfo requestInfo;
@XmlElement(required = true)
protected RequestData requestData;
/**
* Gets the value of the requestInfo property.
*
* @return
* possible object is
* {@link SyncMessageInfo }
*
*/
public SyncMessageInfo getRequestInfo() {
return requestInfo;
}
/**
* Sets the value of the requestInfo property.
*
* @param value
* allowed object is
* {@link SyncMessageInfo }
*
*/
public void setRequestInfo(SyncMessageInfo value) {
this.requestInfo = value;
}
/**
* Gets the value of the requestData property.
*
* @return
* possible object is
* {@link RequestData }
*
*/
public RequestData getRequestData() {
return requestData;
}
/**
* Sets the value of the requestData property.
*
* @param value
* allowed object is
* {@link RequestData }
*
*/
public void setRequestData(RequestData value) {
this.requestData = value;
}
}
package kz.arta.nca_iiscon.shep;
import javax.xml.bind.annotation.*;
/**
* ���������� � ��������� ������
*
* <p>Java class for SyncSendMessageResponse complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="SyncSendMessageResponse">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="responseInfo" type="{http://bip.bee.kz/SyncChannel/v10/Types}SyncMessageInfoResponse"/>
* &lt;element name="responseData" type="{http://bip.bee.kz/SyncChannel/v10/Types/Response}ResponseData"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "SyncSendMessageResponse", namespace = "http://bip.bee.kz/SyncChannel/v10/Types/Response", propOrder = {
"responseInfo",
"responseData"
})
@XmlRootElement
public class SyncSendMessageResponse {
@XmlElement(required = true)
protected SyncMessageInfoResponse responseInfo;
@XmlElement(required = true)
protected ResponseData responseData;
/**
* Gets the value of the responseInfo property.
*
* @return
* possible object is
* {@link SyncMessageInfoResponse }
*
*/
public SyncMessageInfoResponse getResponseInfo() {
return responseInfo;
}
/**
* Sets the value of the responseInfo property.
*
* @param value
* allowed object is
* {@link SyncMessageInfoResponse }
*
*/
public void setResponseInfo(SyncMessageInfoResponse value) {
this.responseInfo = value;
}
/**
* Gets the value of the responseData property.
*
* @return
* possible object is
* {@link ResponseData }
*
*/
public ResponseData getResponseData() {
return responseData;
}
/**
* Sets the value of the responseData property.
*
* @param value
* allowed object is
* {@link ResponseData }
*
*/
public void setResponseData(ResponseData value) {
this.responseData = value;
}
}
@javax.xml.bind.annotation.XmlSchema(namespace = "http://bip.bee.kz/common/v10/Types")
package kz.arta.nca_iiscon.shep;
package kz.arta.nca_iiscon.util;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import lombok.extern.slf4j.Slf4j;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
@Slf4j
public class XmlToJsonUtil {
private static final ObjectMapper objectMapper = new ObjectMapper();
/**
* Извлекает XML из поля data и конвертирует в JSON
*/
public static String extractDataAsJson(Object response) {
try {
// Конвертируем response в JSON
String responseJson = objectMapper.writeValueAsString(response);
JsonNode rootNode = objectMapper.readTree(responseJson);
// Получаем XML строку из responseData.data
JsonNode dataNode = rootNode.at("/responseData/data");
if (dataNode.isMissingNode() || dataNode.isNull()) {
log.warn("Data node not found in response");
return "{}";
}
String xmlString = dataNode.asText();
// Парсим XML и конвертируем в JSON
return xmlToJson(xmlString);
} catch (Exception e) {
log.error("Error extracting data as JSON", e);
return "{\"error\": \"Failed to parse response\"}";
}
}
/**
* Конвертирует XML строку в JSON
*/
public static String xmlToJson(String xmlString) {
try {
// Парсим XML
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
ByteArrayInputStream input = new ByteArrayInputStream(
xmlString.getBytes(StandardCharsets.UTF_8)
);
Document doc = builder.parse(input);
// Конвертируем в JSON
ObjectNode jsonNode = objectMapper.createObjectNode();
Element root = doc.getDocumentElement();
parseElement(root, jsonNode);
return objectMapper.writerWithDefaultPrettyPrinter()
.writeValueAsString(jsonNode);
} catch (Exception e) {
log.error("Error converting XML to JSON", e);
return "{\"error\": \"Failed to parse XML\"}";
}
}
/**
* Рекурсивно парсит XML элемент в JSON
*/
private static void parseElement(Element element, ObjectNode parentNode) {
String nodeName = getCleanName(element);
NodeList children = element.getChildNodes();
boolean hasElementChildren = false;
StringBuilder textContent = new StringBuilder();
// Проверяем, есть ли дочерние элементы
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
hasElementChildren = true;
} else if (child.getNodeType() == Node.TEXT_NODE) {
String text = child.getTextContent().trim();
if (!text.isEmpty()) {
textContent.append(text);
}
}
}
if (hasElementChildren) {
// Элемент имеет дочерние элементы
ObjectNode childNode = objectMapper.createObjectNode();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
parseElement((Element) child, childNode);
}
}
parentNode.set(nodeName, childNode);
} else {
// Листовой элемент - добавляем текст
String text = textContent.toString();
if (!text.isEmpty()) {
parentNode.put(nodeName, text);
} else {
parentNode.put(nodeName, "");
}
}
}
/**
* Убирает namespace префикс из имени элемента
*/
private static String getCleanName(Element element) {
String localName = element.getLocalName();
return localName != null ? localName : element.getNodeName();
}
/**
* Конвертирует XML в JSON без pretty print
*/
public static String xmlToJsonCompact(String xmlString) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
ByteArrayInputStream input = new ByteArrayInputStream(
xmlString.getBytes(StandardCharsets.UTF_8)
);
Document doc = builder.parse(input);
ObjectNode jsonNode = objectMapper.createObjectNode();
Element root = doc.getDocumentElement();
parseElement(root, jsonNode);
return objectMapper.writeValueAsString(jsonNode);
} catch (Exception e) {
log.error("Error converting XML to JSON", e);
return "{\"error\": \"Failed to parse XML\"}";
}
}
}
\ No newline at end of file
spring.application.name=nca_iiscon
service_id=nca_iiscon
forward_service_id=nca_iiscon
service_url=http://192.168.14.19:9580/ws/SyncChannelService.wsdl
login=EISDS
password=8zDV~U4OUo
server.port=13010
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment