bambyzas
bambyzas
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 11/4/2024 in #java-help
how to properly config my application logging?
hey guys. i have java spring app. and on the server its running as a service. heres my application123.service:
[Unit]
Description=application123
After=syslog.target
[Service]
User=appl
Environment="JAVA_OPTS=-Xmx128m"
ExecStart=/usr/local/bin/application123-1.0.jar --spring.config.location=/etc/spring/ --spring.config.name=application123
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
[Unit]
Description=application123
After=syslog.target
[Service]
User=appl
Environment="JAVA_OPTS=-Xmx128m"
ExecStart=/usr/local/bin/application123-1.0.jar --spring.config.location=/etc/spring/ --spring.config.name=application123
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
Now when this service runs on the server, everything is logged to syslog. And the thing is that id want to log everything to separate file. smth like application123.log. so my question is should i edit my application123.service file, or should i edit application.yaml file? thanks
8 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 10/14/2024 in #java-help
Soap request gives me 404 and "No endpoint mapping" even if everything is correct
Hello everyone. Its been almost a week and I still cant find an error and the reason why I am getting this kind of error. The thing is that my endpoint is correct, everything is set up fine. Earlier this endpoint had different name and everything worked fine. And now after changing the endpoint name everything just broke. Things I tried: asking chat gpt and gemini, asking for help on different discord servers, googling and browsing stackoverflow. The thing is that I cannot change the request body and I just need to use this request body. This is my Java code: https://pastecode.io/s/antg289v xsd and wsdl: https://pastecode.io/s/7142nmnr request body: https://pastecode.io/s/ng61346m console log: https://pastecode.io/s/1wg2oi2f Could somebody take a look and help me out? Huge thanks
6 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 10/9/2024 in #java-help
No endpoint mapping found for [SaajSoapMessage idcheck]
hi guys. im developing soap service in java spring and i keep getting No endpoint mapping found for [SaajSoapMessage idcheck] erro. can smb pls help me out? My java code: https://pastecode.io/s/antg289v xsd and wsdl: https://pastecode.io/s/7142nmnr request body: https://pastecode.io/s/ng61346m thanks alot
5 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 10/7/2024 in #java-help
java variables need to have the same name like in SOAP request?
hi guys. i have soap service in java spring. i have this dto class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"userid",
"trans_id"
})
@XmlRootElement(name = "idCheckRequest", namespace = "http://mycompany.lt/soap-web-service")
@Data
public class PerlasCheckIdRequestDTO {
@NotNull(message = "userId cant be null")
@Size(max = 32, message = "userId too long")
@XmlElement(name = "userid", required = true, namespace = "http://mycompany.lt/soap-web-service" )
private String userId;

@NotNull(message = "transactionId cant be null")
@Size(max = 100, message = "transactionId too long")
@XmlElement(name = "trans_id", required = true, namespace = "http://mycompany.lt/soap-web-service")
private String transactionId;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"userid",
"trans_id"
})
@XmlRootElement(name = "idCheckRequest", namespace = "http://mycompany.lt/soap-web-service")
@Data
public class PerlasCheckIdRequestDTO {
@NotNull(message = "userId cant be null")
@Size(max = 32, message = "userId too long")
@XmlElement(name = "userid", required = true, namespace = "http://mycompany.lt/soap-web-service" )
private String userId;

@NotNull(message = "transactionId cant be null")
@Size(max = 100, message = "transactionId too long")
@XmlElement(name = "trans_id", required = true, namespace = "http://mycompany.lt/soap-web-service")
private String transactionId;
}
i send this request body:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<soap:idcheck>
<soap:trans_id>903</soap:trans_id>
<soap:userid>903</soap:userid>
</soap:idcheck>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<soap:idcheck>
<soap:trans_id>903</soap:trans_id>
<soap:userid>903</soap:userid>
</soap:idcheck>
</soapenv:Body>
</soapenv:Envelope>
but i get:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">4 counts of IllegalAnnotationExceptions</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Server</faultcode>
<faultstring xml:lang="en">4 counts of IllegalAnnotationExceptions</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
i noticed that if i name my java vars the same like they are named in request xml, everything is fine. But the thing is that my code gets messy. Is there a fix for this scenario?
4 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 10/7/2024 in #java-help
soap request give me 400 bad request
hi guys. i have soap service in java spring. i have this dto class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"userid",
"trans_id"
})
@XmlRootElement(name = "idCheckRequest", namespace = "http://mycompany.lt/soap-web-service")
@Data
public class PerlasCheckIdRequestDTO {
@NotNull(message = "userId cant be null")
@Size(max = 32, message = "userId too long")
@XmlElement(name = "userid", required = true, namespace = "http://mycompany.lt/soap-web-service" )
private String userId;

@NotNull(message = "transactionId cant be null")
@Size(max = 100, message = "transactionId too long")
@XmlElement(name = "trans_id", required = true, namespace = "http://mycompany.lt/soap-web-service")
private String transactionId;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"userid",
"trans_id"
})
@XmlRootElement(name = "idCheckRequest", namespace = "http://mycompany.lt/soap-web-service")
@Data
public class PerlasCheckIdRequestDTO {
@NotNull(message = "userId cant be null")
@Size(max = 32, message = "userId too long")
@XmlElement(name = "userid", required = true, namespace = "http://mycompany.lt/soap-web-service" )
private String userId;

@NotNull(message = "transactionId cant be null")
@Size(max = 100, message = "transactionId too long")
@XmlElement(name = "trans_id", required = true, namespace = "http://mycompany.lt/soap-web-service")
private String transactionId;
}
i send this request body:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>
<soapenv:Body>
<idcheck soapenv:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/>
<userid xsi:type="xsd:string">903</userid>
<trans_id xsi:type="xsd:string">903</trans_id>
</idcheck>
</soapenv:Body>
</soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsd=http://www.w3.org/2001/XMLSchema xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance>
<soapenv:Body>
<idcheck soapenv:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/>
<userid xsi:type="xsd:string">903</userid>
<trans_id xsi:type="xsd:string">903</trans_id>
</idcheck>
</soapenv:Body>
</soapenv:Envelope>
but i just get 400 bad request. can smb help me out? chatgpt doesnt help at all
9 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 10/3/2024 in #java-help
how to find WSDL file location in my SOAP webservice?
hey guys. i have soap webservice that is running on my server. i can call it with postman: http://dev.mycompany.lt/bgw/perlas then i add needed body and receive expected response. everythings fine. but i was wondering what is the location of my wsdl file? can smb help me out? thx
8 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 9/27/2024 in #java-help
WebSecurityConfig in java spring app doesnt work
hey guys. can smb help me out? i have java spring app runing on my server dev2. on the server i also have nginx basic auth and proxy configured. now when i do the request to http://dev2.mysite.lt/bgw/perlas i get asked for my nginx basic auth credentials. i enter them, and later im prompted with another login page thats comming from my app. my WebSecurityConfig looks like this:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private MyUserDetailsService userDetailsService;

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/perlas").permitAll()

.anyRequest().authenticated()
.and().formLogin().loginPage("/login").permitAll()
.and().logout().permitAll()
.and().csrf().disable();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
auth.authenticationProvider(authProvider());
}
@Bean
public PasswordEncoder passwordEncoder() {
return new CryptEncoder();
}
@Bean
public DaoAuthenticationProvider authProvider() {
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService);
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
}
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Autowired
private MyUserDetailsService userDetailsService;

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/perlas").permitAll()

.anyRequest().authenticated()
.and().formLogin().loginPage("/login").permitAll()
.and().logout().permitAll()
.and().csrf().disable();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
auth.authenticationProvider(authProvider());
}
@Bean
public PasswordEncoder passwordEncoder() {
return new CryptEncoder();
}
@Bean
public DaoAuthenticationProvider authProvider() {
DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService);
authProvider.setPasswordEncoder(passwordEncoder());
return authProvider;
}
}
can smb help me out? thx
6 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 9/24/2024 in #java-help
what password to enter when doing git push?
hey guys. can smb help me out with git? I tried googling but theres no normal and simple answer. the more i read the less i understand. i did git commit -m "my message". then when i try to do git push i get:
banana@dev2:/var/www/lms2$ git push
[email protected]'s password:
banana@dev2:/var/www/lms2$ git push
[email protected]'s password:
what password do i need to enter? can smb explain?
63 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 9/23/2024 in #java-help
how to enable basic auth in java spring app?
hey guys. i have java spring app. in WebSecurityConfig i have this:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/perlas").permitAll()
.anyRequest().authenticated()
.and().formLogin().loginPage("/login").permitAll()
.and().logout().permitAll()
.and().csrf().disable();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/perlas").permitAll()
.anyRequest().authenticated()
.and().formLogin().loginPage("/login").permitAll()
.and().logout().permitAll()
.and().csrf().disable();
}
and i want to enable basic auth. i know that i can do it in nginx, but i was wondering if i can do it in my spring app config somehow. can smb help me out? thx
8 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 9/16/2024 in #java-help
how to test my scheduled methods locally?
hey guys. so i have java spring app. in the app i have a 2 methods annotated with @Scheduled and each method has 2 cron expressions (one for work days, one for weekend). i deploy my app to the server. and on the same server i have cron jobs and thats how my code is being scheduled. but my question is how to locally test if my cron jobs for these two methods work fine?
4 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 9/16/2024 in #java-help
how to properly update spring version?
hi guys. i have java project and current spring version is 2.2.6. i need to update the version to the newest. as i understand its 3.3.3. so i have a couple of questions; 1. since i use gradle, i just need to change the version here?
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
2. is there smth to look out for when updating spring version in my project? thanks in advance
5 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 9/12/2024 in #java-help
how to return multiple objects in SOAP webservice?
hey guys. im developing SOAP webservice in java and i have a question. there are two operations checkId and createSale. and there are CheckIdRequestDTO, CheckIdResponseDTO, CreateSaleRequestDTO, CreateSaleResponseDTO. when validating checkId request and there are some errors, i set needed CheckIdResponseDTO fields to needed values and return the DTO and everything is fine. so my endpoint returns CheckIdResponseDTO in both cases: if its ok, or theres an error. But now im having trouble with createSale request. im validating CreateSaleRequestDTO, and if theres an error i dont have anything to return. I was thinking about constructing something like CreateSaleRequestErrorDTO. but then my endpoint cant return it. this is my endpoint so far:
@Endpoint
@Validated
public class PerlasEndpoint {
@Autowired
PerlasService perlasService;
private static final String SOAP_NAMESPACE="http://mycompany.lt/soap-web-service";

@PayloadRoot(namespace = SOAP_NAMESPACE,localPart = "idCheckRequest")
@ResponsePayload
public PerlasCheckIdResponseDTO checkId(@Valid @RequestPayload PerlasCheckIdRequestDTO perlasCheckIdRequestDTO) {
Optional<PerlasCheckIdResponseDTO> validationResult=perlasService.validateCheckIdRequest(perlasCheckIdRequestDTO, "CHECK ID");

if (validationResult.isPresent()) {
return validationResult.get();
}

PerlasCheckIdResponseDTO perlasCheckIdResponseDTO = perlasService.checkId(perlasCheckIdRequestDTO);

return perlasCheckIdResponseDTO;
}

@PayloadRoot(namespace = SOAP_NAMESPACE, localPart = "saleRequest")
@ResponsePayload
public PerlasSaleResponseDTO createSale(@Valid @RequestPayload PerlasSaleRequestDTO perlasSaleRequestDTO) {
PerlasSaleResponseDTO perlasSaleResponseDTO=perlasService.createSale(perlasSaleRequestDTO);

return perlasSaleResponseDTO;
}
}
@Endpoint
@Validated
public class PerlasEndpoint {
@Autowired
PerlasService perlasService;
private static final String SOAP_NAMESPACE="http://mycompany.lt/soap-web-service";

@PayloadRoot(namespace = SOAP_NAMESPACE,localPart = "idCheckRequest")
@ResponsePayload
public PerlasCheckIdResponseDTO checkId(@Valid @RequestPayload PerlasCheckIdRequestDTO perlasCheckIdRequestDTO) {
Optional<PerlasCheckIdResponseDTO> validationResult=perlasService.validateCheckIdRequest(perlasCheckIdRequestDTO, "CHECK ID");

if (validationResult.isPresent()) {
return validationResult.get();
}

PerlasCheckIdResponseDTO perlasCheckIdResponseDTO = perlasService.checkId(perlasCheckIdRequestDTO);

return perlasCheckIdResponseDTO;
}

@PayloadRoot(namespace = SOAP_NAMESPACE, localPart = "saleRequest")
@ResponsePayload
public PerlasSaleResponseDTO createSale(@Valid @RequestPayload PerlasSaleRequestDTO perlasSaleRequestDTO) {
PerlasSaleResponseDTO perlasSaleResponseDTO=perlasService.createSale(perlasSaleRequestDTO);

return perlasSaleResponseDTO;
}
}
and idk what to do in this situation. can smb help me out? thx
9 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 9/12/2024 in #java-help
what data type to use for storing ids?
hi guys. in java code i will need to use/store ids, that look like 11000000035. what data type to use? long or just String? because int in my case doesnt have enough storage for symbols. thanks
12 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 8/16/2024 in #java-help
exception handling in SOAP webservices
hey guys. i have a question about SOAP webservice. i have this piece of code in my service layer:
Optional<Customer> customer=customerRepository.findById(Long.valueOf(perlasIdCheckRequestDTO.getUserId()));
if (customer.isEmpty()) {
log.info("PerlasService.checkId.NoCustomerException.CustomerId:{}.TransactionId:{}",perlasIdCheckRequestDTO.getUserId(),perlasIdCheckRequestDTO.getTransactionId());

throw new NoCustomerException("No customer with customerId:"+perlasIdCheckRequestDTO.getUserId());
}
Optional<Customer> customer=customerRepository.findById(Long.valueOf(perlasIdCheckRequestDTO.getUserId()));
if (customer.isEmpty()) {
log.info("PerlasService.checkId.NoCustomerException.CustomerId:{}.TransactionId:{}",perlasIdCheckRequestDTO.getUserId(),perlasIdCheckRequestDTO.getTransactionId());

throw new NoCustomerException("No customer with customerId:"+perlasIdCheckRequestDTO.getUserId());
}
and i have this exception:
@Getter
public class NoCustomerException extends RuntimeException {
public NoCustomerException(String message) {
super(message);
}
}
@Getter
public class NoCustomerException extends RuntimeException {
public NoCustomerException(String message) {
super(message);
}
}
and the exception is later handled by the RestResponseEntityExceptionHandler. so i have a couple of questions: 1. can i use the same exception? or do i need to create a duplicate one that will only be used for SOAP service? can i reuse the exception from my REST service? 2. how to handle the exceptions in SOAP webservices? i tried googling but honestly didnt understand a thing. can smb help me out? thx
4 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 8/16/2024 in #java-help
SOAP service returns 404
hi guys. im developing SOAP web service. but when i call it with SOAP UI, i get
HTTP/1.1 404
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Length: 0
Date: Wed, 14 Aug 2024 13:52:53 GMT
Keep-Alive: timeout=60
Connection: keep-alive
HTTP/1.1 404
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Content-Length: 0
Date: Wed, 14 Aug 2024 13:52:53 GMT
Keep-Alive: timeout=60
Connection: keep-alive
my code:
@Endpoint
public class PerlasEndpoint{
private static final String SOAP_NAMESPACE="mynamespace";
@PayloadRoot(namespace=SOAP_NAMESPACE,localPart="idCheckRequest")
@ResponsePayload
public String checkId(@RequestPayload PerlasIdCheckRequestDTO perlasIdCheckRequestDTO) throws IOException{
System.out.println("ASD");
return "perlasIdCheckResponseDTO";
}
}
@Endpoint
public class PerlasEndpoint{
private static final String SOAP_NAMESPACE="mynamespace";
@PayloadRoot(namespace=SOAP_NAMESPACE,localPart="idCheckRequest")
@ResponsePayload
public String checkId(@RequestPayload PerlasIdCheckRequestDTO perlasIdCheckRequestDTO) throws IOException{
System.out.println("ASD");
return "perlasIdCheckResponseDTO";
}
}
@EnableWs
@Configuration
public class PerlasSoapConfig{
@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
messageDispatcherServlet.setApplicationContext(applicationContext);
messageDispatcherServlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean<MessageDispatcherServlet>(messageDispatcherServlet, "/ws/*");
}
@Bean(name = "perlas")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema xsdSchema) {
DefaultWsdl11Definition defaultWsdl11Definition = new DefaultWsdl11Definition();
defaultWsdl11Definition.setPortTypeName("Perlas");
defaultWsdl11Definition.setLocationUri("/ws");
defaultWsdl11Definition.setTargetNamespace("mynamespace");
defaultWsdl11Definition.setSchema(xsdSchema);
return defaultWsdl11Definition;
}
@Bean
public XsdSchema xsdSchema() {
return new SimpleXsdSchema(new ClassPathResource("perlas/perlas.xsd"));
}
}
@EnableWs
@Configuration
public class PerlasSoapConfig{
@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
messageDispatcherServlet.setApplicationContext(applicationContext);
messageDispatcherServlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean<MessageDispatcherServlet>(messageDispatcherServlet, "/ws/*");
}
@Bean(name = "perlas")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema xsdSchema) {
DefaultWsdl11Definition defaultWsdl11Definition = new DefaultWsdl11Definition();
defaultWsdl11Definition.setPortTypeName("Perlas");
defaultWsdl11Definition.setLocationUri("/ws");
defaultWsdl11Definition.setTargetNamespace("mynamespace");
defaultWsdl11Definition.setSchema(xsdSchema);
return defaultWsdl11Definition;
}
@Bean
public XsdSchema xsdSchema() {
return new SimpleXsdSchema(new ClassPathResource("perlas/perlas.xsd"));
}
}
idk what im doing wrong. can smb help me out? thx
4 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 8/7/2024 in #java-help
how to validate three similar objects that come into my controller?
hey guys. i have an api with 3 endpoints. each endpoint reveices the same DTO object. but the values vary. 1st endpoint receives object with these fields: transactionId, clientId, amount, signature 2nd endpoint receives object with these fields: transactionId, amount, signature 3rd endpoint: transactionId, signature signature is generated before calling the first endpoint. its just transactionId, clientId and amount concatenated together. and then the same signature is used in the 2nd and 3rd endpoints/requests. i want to have a method to somehow validate signature field in requests. i dont know how can i have a generic/universal method that can be used for all three objects. would it mean that i need to have three different methods? any ideas? thanks alot
9 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 8/7/2024 in #java-help
formulate JPA method to update column
hey guys. i have a question about java spring. i have a DB table and a repository in my code. in my service i want to find a DB row/record by transactionId, and change record's status column/field value. i was thinking about boolean updateSalesOrderByTransactionId(@Param("transactionId")); but i dont know how to say that i want to update status column? can smb help me out? thanks
9 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 8/6/2024 in #java-help
how to fix my WSDL file for SOAP service?
hey guys. can smb help me out with WSDL file? im working on a SOAP webservice, and as i understand, there are some issues with my WSDL file. this is my file: https://pastecode.io/s/c78xizki and i have these questions 1. why theres wsdl: before message, part or any other tag? 2. why there are so many xmlnss? i.e. xmlns:soap, xmlns:s, xmlns:wsdl, etc? i feel that theres too much duplication 3. what does documentation tag even mean? how does it even work? google says The documentation element is used to enter text comments in a schema. but i dont have any schema tags??? 4. what to us for soapAction attribute? what value should it have? 5. as i understand, there are 4 requests: idCheckSoapIn, idCheckSoapOut, saleSoapIn, saleSoapOut. but what the hell is CustomerSoap? 6. what do i even need to do after the 46th line? everything before 46th line makes sense - i just desribe what requests and responses my webservice will have. but what is going on after the 46th line? thanks in advance
4 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 8/5/2024 in #java-help
i keep getting error "Attribute value must be constant". can smb help me out?
hey guys. i have this:
@Endpoint
public class MyEndpoint {

@Autowired
MyService myService;
@Autowired
AppConfig appConfig;
private final String SOAP_NAMESPACE=appConfig.getSoapNamespace();

@PayloadRoot(namespace = SOAP_NAMESPACE,localPart = "idCheckRequest")
@ResponsePayload
public idCheckResponseDTO checkId(@RequestPayload idCheckRequestDTO idCheckRequestDTO) throws IOException {
//code
}
}
@Endpoint
public class MyEndpoint {

@Autowired
MyService myService;
@Autowired
AppConfig appConfig;
private final String SOAP_NAMESPACE=appConfig.getSoapNamespace();

@PayloadRoot(namespace = SOAP_NAMESPACE,localPart = "idCheckRequest")
@ResponsePayload
public idCheckResponseDTO checkId(@RequestPayload idCheckRequestDTO idCheckRequestDTO) throws IOException {
//code
}
}
but i get an error from SOAP_NAMESPACE that says: Attribute value must be constant. can smb help me out with it? bc googling doesnt help. thanks in advance.
13 replies
JCHJava Community | Help. Code. Learn.
Created by bambyzas on 8/2/2024 in #java-help
how to create SOAP webservice?
hey guys. i need to code soap webservice. i was wondering if you could help me out with a couple of questions? 1. i have these dependencies in my gradle file. do ineed smth more?
dependencies {
xsd2java "com.sun.xml.bind:jaxb-xjc:2.2.6"
xsd2java "com.sun.xml.bind:jaxb-impl:2.2.6"
xsd2java "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
xsd2java "org.glassfish.jaxb:jaxb-runtime:2.3.2"

implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-security'

implementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.boot:spring-boot-devtools'

implementation 'io.springfox:springfox-swagger2:3.0.0' //:
implementation 'io.springfox:springfox-swagger-ui:3.0.0' //:2.9.2

implementation 'commons-codec:commons-codec:1.14' //:2.9.2
implementation 'org.apache.httpcomponents:httpclient:4.5.14'

compileOnly 'org.projectlombok:lombok:1.18.32'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testCompile group: 'junit', name: 'junit', version: '4.12'

}
dependencies {
xsd2java "com.sun.xml.bind:jaxb-xjc:2.2.6"
xsd2java "com.sun.xml.bind:jaxb-impl:2.2.6"
xsd2java "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
xsd2java "org.glassfish.jaxb:jaxb-runtime:2.3.2"

implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-security'

implementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.boot:spring-boot-devtools'

implementation 'io.springfox:springfox-swagger2:3.0.0' //:
implementation 'io.springfox:springfox-swagger-ui:3.0.0' //:2.9.2

implementation 'commons-codec:commons-codec:1.14' //:2.9.2
implementation 'org.apache.httpcomponents:httpclient:4.5.14'

compileOnly 'org.projectlombok:lombok:1.18.32'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testCompile group: 'junit', name: 'junit', version: '4.12'

}
2. im given a wsdl file. do i need to have an xsd file too? 3. do i still need a controller? thanks in advance
56 replies