You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Eclipse Java Jaxb2插件生成WSDL时CreateRequest方法缺失求助

Why Your CreateRequest Method Isn't Appearing in the Generated WSDL

Let’s break down the root cause and fix this issue step by step:

The core problem here is that your XSD only defines XML data structures (types and root elements for requests/responses), but a complete WSDL requires a service contract that maps those data structures to SOAP operations, messages, and ports.

The Maven JAXB2 plugin only handles converting XSD schemas to Java data classes—it doesn’t define the actual SOAP service interface that tells your framework which operations to expose. Without that service interface, your SOAP configuration has no way to generate the xs:message, portType, and binding sections needed for SoapUI to send valid requests.

Step-by-Step Solution

1. Create a JAX-WS Service Interface

You need to define a service interface with JAX-WS annotations to link your JAXB-generated Java objects to a SOAP operation. Here’s an example tailored to your XSD:

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import com.your.package.CreateRequestInput;
import com.your.package.CreateRequestOutput;

@WebService(targetNamespace = "http://www.ima.eu/xml/cattolica")
public interface RequestService {

    @WebMethod(operationName = "CreateRequest")
    @WebResult(name = "CreateRequestOutput", targetNamespace = "http://www.ima.eu/xml/cattolica")
    CreateRequestOutput createRequest(
        @WebParam(name = "CreateRequestInput", targetNamespace = "http://www.ima.eu/xml/cattolica")
        CreateRequestInput input
    );
}
  • @WebService ties the interface to your XSD’s target namespace.
  • @WebMethod marks the method as a SOAP operation named CreateRequest.
  • @WebParam and @WebResult map method parameters/return values directly to your XSD’s root elements.

2. Implement the Service Interface

Write a concrete implementation with your business logic:

public class RequestServiceImpl implements RequestService {

    @Override
    public CreateRequestOutput createRequest(CreateRequestInput input) {
        // Add your business logic here to process the input
        CreateRequestOutput output = new CreateRequestOutput();
        CreateRequest response = new CreateRequest();
        response.setIdCRM("GENERATED-CRM-ID");
        response.setStatus("SUCCESS");
        output.setCreateRequest(response);
        return output;
    }
}

3. Update Your SOAP Configuration

Depending on your framework, configure the service to be exposed:

For Plain JAX-WS (No Spring)

Publish the service directly on startup:

import javax.xml.ws.Endpoint;

public class ServicePublisher {
    public static void main(String[] args) {
        Endpoint.publish("http://localhost:8080/requestService", new RequestServiceImpl());
    }
}

For Spring (Traditional or Boot)

Use Spring’s JAX-WS support to expose the service:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.jaxws.SimpleJaxWsServiceExporter;

@Configuration
public class SoapConfig {

    @Bean
    public SimpleJaxWsServiceExporter jaxWsServiceExporter() {
        SimpleJaxWsServiceExporter exporter = new SimpleJaxWsServiceExporter();
        exporter.setBaseAddress("http://localhost:8080/");
        return exporter;
    }

    @Bean
    public RequestService requestService() {
        return new RequestServiceImpl();
    }
}

4. Verify the WSDL

Start your application and visit the WSDL URL (e.g., http://localhost:8080/requestService?wsdl). You’ll now see:

  • The existing xs:types section (from your XSD)
  • xs:message definitions for the CreateRequest request and response
  • A portType with the CreateRequest operation
  • SOAP binding and port elements

This will allow SoapUI to parse the WSDL and generate valid request/response messages.

内容的提问来源于stack exchange,提问作者Marco Bozzola

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 12:48:11