我遇到此問題。我使用Seam Framework創建了一個運行在JBoss 5之上的Web服務。該Web服務有一個稱爲「登錄」的單一方法。當我消費從Java客戶端的服務,它工作正常,但是當我嘗試從Visual FoxPro中的客戶端(我真正需要的)消耗,我得到一個錯誤信息:從JBoss的從Visual FoxPro調用JBoss Web Service時出現「無法找到子元素」錯誤
Error 1429 - OLE IDispatch exception code 0 from ?: Cannot find child element: username
錯誤堆棧跟蹤:
12:02:32,396 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
org.jboss.ws.WSException: Cannot find child element: username
at org.jboss.ws.core.CommonSOAPBinding.getParameterFromMessage(CommonSOAPBinding.java:917)
at org.jboss.ws.core.CommonSOAPBinding.unbindRequestMessage(CommonSOAPBinding.java:361)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:197)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:474)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:295)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
我的Web服務類:
@Name("ServiceName")
@WebService(name = "ServiceName", serviceName = "ServiceName")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@Stateless
public class ServiceName implements ServiceNameRemote {
@WebMethod
@Override
public boolean login(@WebParam(name = "username") String username, @WebParam(name = "password") String password) {
// logic..
return result;
}
}
從localhost:8080/app-app/ServiceName?wsdl
<definitions name="ServiceName"
targetNamespace="http://service.namespace/"
xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://service.namespace/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types />
<message name="ServiceName_login">
<part name="username" type="xsd:string" />
<part name="password" type="xsd:string" />
</message>
<portType name="ServiceName">
<operation name="login" parameterOrder="username password">
<input message="tns:ServiceName_login" />
<output message="tns:ServiceName_loginResponse" />
</operation>
</portType>
<binding name="ServiceNameBinding" type="tns:ServiceName">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="login">
<soap:operation soapAction="" />
<input>
<soap:body namespace="http://service.namespace/"
use="literal" />
</input>
<output>
<soap:body namespace="http://service.namespace/"
use="literal" />
</output>
</operation>
</binding>
<service name="ServiceName">
<port binding="tns:ServiceNameBinding" name="ServiceNamePort">
<soap:address
location="http://localhost:8080/app-app/ServiceName" />
</port>
</service>
</definitions>
客戶端代碼(使用MS SOAP工具包3.0):
LOCAL loServiceNamePort AS "XML Web Service"
* LOCAL loServiceNamePort AS "MSSOAP.SoapClient30"
* Do not remove or alter following line. It is used to support IntelliSense for your XML Web service.
*__VFPWSDef__: loServiceNamePort = http://localhost:8080/app-app/ServiceName?wsdl , ServiceName , ServiceNamePort
LOCAL loException, lcErrorMsg, loWSHandler
TRY
loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC\")+"_ws3client.vcx")
loServiceNamePort = loWSHandler.SetupClient("http://localhost:8080/app-app/ServiceName?wsdl", "ServiceName", "ServiceNamePort")
* Call your XML Web service here. ex: leResult = loServiceNamePort.SomeMethod()
MESSAGEBOX(loServiceNamePort.login("username", "password"))
CATCH TO loException
lcErrorMsg = "Error: "+TRANSFORM(loException.Errorno)+" - "+loException.Message
DO CASE
CASE VARTYPE(loServiceNamePort)#"O"
* Handle SOAP error connecting to web service
WAIT WINDOW "Error connecting to web service" NOWAIT
CASE !EMPTY(loServiceNamePort.FaultCode)
* Handle SOAP error calling method
lcErrorMsg = lcErrorMsg + CHR(13) + loServiceNamePort.Detail
WAIT WINDOW "SOAP error calling method" NOWAIT
OTHERWISE
* Handle other error
ENDCASE
* Use for debugging purposes
MESSAGEBOX(lcErrorMsg)
FINALLY
ENDTRY
客戶端代碼(使用PocketSOAP):
LOCAL loException, lcErrorMsg, loFactory, loProxy
TRY
loFactory = createObject("pocketsoap.Factory")
loProxy = loFactory.CreateProxy("http://localhost:8080/app-app/ServiceName?wsdl", "http://service.namespace/")
MESSAGEBOX(loProxy.login("username", "password"))
CATCH TO loException
lcErrorMsg = "Error: "+TRANSFORM(loException.Errorno)+" - "+loException.Message
DO CASE
CASE VARTYPE(loServiceNamePort)#"O"
* Handle SOAP error connecting to web service
WAIT WINDOW "Error connecting to web service" NOWAIT
CASE !EMPTY(loServiceNamePort.FaultCode)
* Handle SOAP error calling method
lcErrorMsg = lcErrorMsg + CHR(13) + loServiceNamePort.Detail
WAIT WINDOW "SOAP error calling method" NOWAIT
OTHERWISE
* Handle other error
ENDCASE
* Use for debugging purposes
MESSAGEBOX(lcErrorMsg)
FINALLY
ENDTRY
我一直在尋找一個解釋,爲什麼出現這種情況,但還沒有找到它。我嘗試了幾個Google搜索時發現的東西:我將名稱空間屬性與對應的值添加到@WebParam註釋中,添加了帶名稱和名稱空間的@WebResult註釋,將SOAP綁定從RPC更改爲Document,都無濟於事。任何幫助你可以給我這裏真的很感激。
編輯:我們放棄了SOAP服務,現在正在使用REST服務,我們發現這些服務更容易從Visual Fox中使用,而無需任何橋接應用程序。