Camel CXF WS Producer(POJO格式)调用GetReport报参数数量错误
Let's work through this issue step by step to figure out why you're getting that parameter mismatch error.
First, Understand the Root Cause
The error Expect size 7, Parameter size 4 tells us that CXF is expecting 7 parameters to invoke the GetReport operation, but you're only passing 4. This number directly comes from the method signature of the ReportServiceSoap interface generated by wsdl2java—so our first stop should be checking that file.
Step 1: Check Your Generated SEI Method Signature
Open the tableau.ea.eventcore.api.reportservice.ReportServiceSoap.java file created by wsdl2java and look for the getReport method. It will look something like this (adjust based on your actual code):
public void getReport( GetReport request, AuthTokenHeader authTokenHeader, CredentialsHeader credentialsHeader, javax.xml.ws.Holder<GetReportResponse> responseHolder, javax.xml.ws.Holder<AuthTokenHeader> outAuthTokenHolder, // Additional parameters if your WSDL defines more output/input parts javax.xml.ws.Holder<SomeOtherHeader> extraOutHeader1, javax.xml.ws.Holder<AnotherHeader> extraOutHeader2 );
This is where the "7 parameters" expectation comes from—each input part (body + headers) is a parameter, and each output part (body + headers) is a javax.xml.ws.Holder parameter.
Step 2: Fix Parameter Order & Missing Values
Looking at your current code, there are two critical issues:
- Wrong input header order: Your WSDL defines input headers in the order
AuthTokenHeaderfirst, thenCredentialsHeader, but you're passingcredentialsas the second parameter. - Missing output body holder: You commented out the
Holder<GetReportResponse>which is required for the operation's output body.
Corrected Code Example
Assuming your SEI expects 7 parameters (adjust based on your actual method signature), here's how to construct the parameter list correctly:
GetReport getReport = new GetReport(); // Populate getReport fields as before... CredentialsHeader credentials = new CredentialsHeader(); // Populate credentials fields as before... // Create AuthTokenHeader (even if empty, match the type) AuthTokenHeader authTokenHeader = new AuthTokenHeader(); // If you don't need to set values, you can pass null instead, but keep the position // Create holders for output values javax.xml.ws.Holder<GetReportResponse> responseHolder = new javax.xml.ws.Holder<>(); javax.xml.ws.Holder<AuthTokenHeader> outAuthTokenHolder = new javax.xml.ws.Holder<>(); // Add any additional holders required for extra output parts (to reach 7 parameters) javax.xml.ws.Holder<SomeOtherHeader> extraOutHolder1 = new javax.xml.ws.Holder<>(); javax.xml.ws.Holder<AnotherHeader> extraOutHolder2 = new javax.xml.ws.Holder<>(); List<Object> params = new ArrayList<>(); params.add(getReport); // 1. Input body (GetReport) params.add(authTokenHeader); // 2. First input header (AuthTokenHeader) params.add(credentials); // 3. Second input header (CredentialsHeader) params.add(responseHolder); // 4. Output body holder (GetReportResponse) params.add(outAuthTokenHolder); // 5. Output header holder (AuthTokenHeader) params.add(extraOutHolder1); // 6. Extra output holder 1 (match SEI type) params.add(extraOutHolder2); // 7. Extra output holder 2 (match SEI type) exchange.getIn().setBody(params);
Key Checks to Verify
- Match SEI exactly: Every parameter in your list must match the type and order defined in the
getReportmethod ofReportServiceSoap. If you pass anull, make sure it's for a parameter that acceptsnull(most input parameters do). - Confirm CXF Endpoint config: Double-check that
serviceClass,serviceName, andendpointNamein yourCxfEndpointmatch the generated code and WSDL exactly. ThedataFormat=POJOsetting is correct for your use case. - Avoid skipping parameters: Even if you don't need a header or output value, you can't skip its position in the list—fill it with a
nullor empty object of the correct type.
内容的提问来源于stack exchange,提问作者Sowjanya Mudimala

