问题
I have two code projects both using CXF to use web services. When I make a call from project A to project B, the method I am calling receives null parameters. I've turned on logging and the inbound message does indeed contain the correct parameters. I have also tried calling my service from SoapUI (a webservice testing tool). This passes over the parameters as I expect. Anyone have any ideas what's going wrong?
The service interface:
@WebService
public interface IShortlistService {
public IShortlist createOrUpdateShortlist(@WebParam(name = "sessionId") String sessionId,
@WebParam(name = "datastoreInstance") String datastoreInstance,
@WebParam(name = "datastoreRecordId") String datastoreRecordId);
}
The service impl:
@Name("shortlistService")
@WebService(endpointInterface = "com.oobjects.shortlist.service.IShortlistService", serviceName = "ShortlistService")
@Features(features = "org.apache.cxf.feature.LoggingFeature")
@Transactional
public class ShortlistService implements IShortlistService {
public IShortlist createOrUpdateShortlist(String sessionId, String datastoreInstance,
String datastoreRecordId) {
// At this point all inputs are null
}
}
Logging for inbound message that proves it's OK:
INFO: Inbound Message
----------------------------
Encoding: UTF-8
Content-Type: text/xml; charset=UTF-8
Headers: {cache-control=[no-cache], content-type=[text/xml; charset=UTF-8], connection=[keep-alive], host=[mypc.mycompany.com:8080], content-length=[391], SOAPAction=[""], user-agent=[Apache CXF 2.2.5], Accept=[*/*], pragma=[no-cache]}
Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns1:createOrUpdateShortlist xmlns:ns1="http://service.shortlist.mycompany.com/"><sessionId>854a48b5-922f-4081-9c76-b6d08b58a341</sessionId><datastoreInstance>http://mypc.mycompany.com:8080/shortlist-app/services/ShortlistService</datastoreInstance></ns1:createOrUpdateShortlist></soap:Body></soap:Envelope>
--------------------------------------
The versions of CXF are the same (2.2.5). I can't think what else to check!
Some requested information...
- @Name is a Seam annotation
- Configured programmatically
- Aegis databinding (JAXWS doesn't like interfaces)
回答1:
@Lee Theobald ... there's nothing obvious in your posted question that reveals why it isn't working for you. In this case, the 'answer,' such as it is, is to request assistance on "CXF Users" , and, if necessary, open a JIRA. Playing 20 questions in the question comments isn't very efficient, and there are a lot more CXF-expert eyeballs on that list than here at this point. We could bring an amended question and answer back over here once the mystery is revealed.
回答2:
Okay, the problem resolved as an error. The guy whose interface I was using didn't update from the repository before deploying his service, and as something had changed on his part (a throws clause was removed) that he checked in but didn't deploy, I used the fresher version from the repository. His version of the interface threw an exception, but my version of the interface didn't say so. So:
This error can occur if service provider and service client use a slightly different interface.
来源:https://stackoverflow.com/questions/2087465/web-service-call-via-cxf-gives-null-parameters