Код: Выделить всё
import com.example.client.YourServicePortType; // Generated interface
import com.example.client.YourService; // Generated service class
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
@ApplicationScoped
public class SoapClient {
private static final String WSDL_URL = "http://example.com/your-wsdl?wsdl"; // Replace with actual WSDL URL
public YourServicePortType createServiceClient() {
// Use the generated service interface
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(YourServicePortType.class); // Set the service class
factory.setAddress(WSDL_URL); // Set the service endpoint URL
return (YourServicePortType) factory.create(); // Create client proxy
}
public String invokeService() {
YourServicePortType client = createServiceClient();
// Call the service method. Replace with the actual method name from your generated class
return client.yourServiceMethod("param1", "param2"); // Adjust method name and parameters
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... pring-boot