我正在尝试将在JBoss下运行的Java Web应用程序与QuickBooks Desktop集成,并且我正在使用WebConnector来实现此目的。 我还使用JAX-WS在Java中实现Web服务。 经过一系列已解决的问题,我遇到了一个问题:即当WebConnector尝试调用authenticate方法时,JBoss会抛出以下异常:
[SOAPFaultHelperJAXWS] SOAP request exception
javax.xml.ws.WebServiceException: javax.xml.bind.UnmarshalException:
unexpected element (uri:"", local:"strUserName"). Expected elements are <{http://developer.intuit.com/}strPassword>,<{http://developer.intuit.com/}strUserName>
和
[SOAPFaultHelperJAXWS] SOAP request exception
javax.xml.ws.WebServiceException: javax.xml.bind.UnmarshalException:
unexpected element (uri:"", local:"strVersion"). Expected elements are <{http://developer.intuit.com/}strVersion>
接口
@WebService(name = "QBWebConnectorService", targetNamespace = "http://developer.intuit.com/")
public interface QBWebConnectorService {
@WebMethod
public String serverVersion(
@WebParam(name = "strVersion", targetNamespace = "http://developer.intuit.com/")
String strVersion);
@WebMethod
public String clientVersion(
@WebParam(name = "strVersion", targetNamespace = "http://developer.intuit.com/")
String strVersion);
@WebMethod
public ArrayOfString authenticate(
@WebParam(name = "strUserName", targetNamespace = "http://developer.intuit.com/")
String strUserName,
@WebParam(name = "strPassword", targetNamespace = "http://developer.intuit.com/")
String strPassword);
...
}
实施
@WebService(serviceName = "QBWebConnectorService", targetNamespace = "http://developer.intuit.com/", portName = "QBWebConnector", name = "QBWebConnector", endpointInterface = "com.example.myapp.ws.QBWebConnectorService")
public class QBWebConnector implements QBWebConnectorService {
@Override
public ArrayOfString authenticate(String strUserName, String strPassword) {
ArrayOfString arr = new ArrayOfString();
arr.string = new ArrayList<String>();
arr.string.add("{57F3B8B1-86F1-4fcc-B1EE-566DE1813D20}");
arr.string.add(""); //To use the currently open company, specify an empty string
return arr;
}
...
}
对serverVersion()和clientVersion()的调用按预期执行,没有错误。并且对authenticate()的调用在命名空间中存在此问题。但我无法弄清楚为什么。 任何人都可以提供一些想法吗?感谢...