我在 JAXWS 的实现方面遇到问题,用于公开端点,该端点将在 API 休息或默认 Spring Boot 端口的同一端口中使用肥皂消息。
我正在用这个:
用于从 wsdl 生成代码的插件:org.codehaus.mojo>jaxws-maven-plugin-2.6
Java 11 + Spring boot 2.7.13 + jakarta.xml.ws-api-4.0.1
package net.gencat.salut.sivec.external.cases.config;
import jakarta.xml.ws.Endpoint;
import lombok.extern.slf4j.Slf4j;
import net.gencat.salut.sivec.external.cases.argo.CarregaImpl;
import net.gencat.salut.sivec.external.cases.notification.NotificationSoapImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;
@Configuration
@Slf4j
public class WebServiceConfig {
@Bean
public CarregaImpl carregaImpl() {
return new CarregaImpl();
}
@Bean
public Endpoint publishEndpoint(final SoapProperties soapProperties,CarregaImpl carregaImpl)
{
log.info("Endpoint argo published: {}",soapProperties.getUri());
return Endpoint.publish(soapProperties.getUri(), carregaImpl);
}
}
getURI的值是这样的:http://localhost:8989/ws/
这是我的日志:
我想要的解决方案1
我想知道如何配置 JAXWS Endpoint 以使用与 Spring boot 相同的端口,如果使用我所做的解决方案或实现,我无法使用相同的端口,因为 spring boot 在运行时显示“端口正在使用”
解决方案 2:如果我配置两个不同的端口,当我在 Openshift 中部署此微服务并查看监听上的所有端口时,如何将端点配置为 http://localhost:8989
对于端口 8989,它显示“localhost:8989”而不是“:::8989”默认 Spring Boot 端口是如何显示的,然后我遇到重定向问题,因为无法解析云中的 localhost:8989
有人可以帮助我吗?欢迎任何建议,但如果有一个例子,我们将不胜感激
我有一个应用程序在同一端口上运行 REST 和 SOAP 服务器。不过我使用的是不同的插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>${project.basedir}/src/main/resources/static</source>
</sources>
</configuration>
</plugin>
在我的静态文件夹中,我有我的 xsd 文件。
之后,我的配置类有点不同:
@EnableWs
@Configuration
class WebServiceConfig : WsConfigurerAdapter() {
// Global URL registration
@Bean
fun messageDispatcherServlet(applicationContext: ApplicationContext): ServletRegistrationBean<MessageDispatcherServlet> {
val servlet = MessageDispatcherServlet()
servlet.setApplicationContext(applicationContext)
servlet.isTransformWsdlLocations = true
return ServletRegistrationBean(servlet, "/webservices/*", "/ws/*")
}
@Bean
fun schema1(): XsdSchema {
return SimpleXsdSchema(ClassPathResource("static/schema1.xsd"))
}
@Bean(name = ["Schema1Service"])
fun schema1Definition(accountBalancerSchema: XsdSchema): Wsdl11Definition {
val wsdl11Definition = NoRequestSuffixWsdl11Definition()
wsdl11Definition.setPortTypeName("Schema1Definition")
wsdl11Definition.setLocationUri("/webservices")
wsdl11Definition.setTargetNamespace(Schema1Endpoint.NAMESPACE_URI)
wsdl11Definition.setSchema(schema1)
return wsdl11Definition
}
// ... with new beans for each xsd
}
这是 Kotlin 代码,但概念在 Java 中是相同的。
然后,端点看起来像:
@Endpoint
class Schema1Endpoint(
// All autowired necessary
) {
companion object {
const val NAMESPACE_URI = "https://whatever.your.namespace.is"
}
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "matching def from xsd")
@ResponsePayload
fun function1(@RequestPayload request: Function1Request): Function1Response { // Request & Response are auto generated
// do what you need to here
val response = Function1Response()
// set what you need on the response
return response
}
// All other functions...
}
我希望这有帮助。