测试调用webservice时出错

20 views
Skip to first unread message

wlg

unread,
Jan 8, 2008, 6:27:25 AM1/8/08
to cxf-zh
javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:
175)
at $Proxy16.findsAllResidentPopulation(Unknown Source)
at test.proxyplatform.proxybus.PersonTest.testPerson(PersonTest.java:
48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:
81)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:
38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:
38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)
Caused by: org.apache.cxf.binding.soap.SoapFault: Fault occurred while
processing.
客户端:
public void testPerson()throws Exception{
//URL wsdlURL;
//File wsdlFile=new File("PersonQuery.wsdl");
//if(wsdlFile.exists()){
// wsdlURL=wsdlFile.toURL();
//}
//PersonQueryService ss=new
PersonQueryService(wsdlURL,SERVICE_NAME);

PersonQuery
pquery=(PersonQuery)context.getBean("client_personQuery");
String sql="select * from users";
List tep=(List)pquery.findsAllResidentPopulation(sql);
System.out.println("结果:"+tep);
}
配置文件:
<jaxws:client id="client_personQuery"
serviceClass="org.proxyplatform.webservices.PersonQuery"
address="http://127.0.0.1:81/Proxypaltform/ws/personQueryService">
</jaxws:client>
另外:在返回结果时,取不到值
public List<ResidentPopulation> findsAllResidentPopulation(String
sql);
在客户端调用时,取不到值。

jim ma

unread,
Jan 8, 2008, 9:12:16 PM1/8/08
to cxf...@googlegroups.com
给出你的wsdl看看.Sever端出错了吗?

On Jan 8, 2008 7:27 PM, wlg <wuli...@hotmail.com> wrote:

javax.xml.ws.soap.SOAPFaultException: Fault occurred while processing.
       at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:
175)
       at $Proxy16.findsAllResidentPopulation(Unknown Source)
       at test.proxyplatform.proxybus.PersonTest.testPerson(PersonTest.java:
48)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:
39)
       at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at junit.framework.TestCase.runTest(TestCase.java:154)
       at junit.framework.TestCase.runBare(TestCase.java:127)
       at junit.framework.TestResult$1.protect(TestResult.java:106)
       at junit.framework.TestResult.runProtected (TestResult.java:124)

wlg

unread,
Jan 9, 2008, 7:44:21 AM1/9/08
to cxf-zh

<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:ns1="http://webservices.proxyplatform.org/" xmlns:soap="http://
schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://proxy.org/
personquery" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="PersonQueryService" targetNamespace="http://proxy.org/
personquery">
<wsdl:import location="http://127.0.0.1:81/Proxypaltform/ws/
personQueryService?wsdl=PersonQuery.wsdl" namespace="http://
webservices.proxyplatform.org/" />
- <wsdl:binding name="PersonQueryServiceSoapBinding"
type="ns1:PersonQuery">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/
soap/http" />
- <wsdl:operation name="findAllTempPopulations">
<soap:operation soapAction="" style="document" />
- <wsdl:input name="findAllTempPopulations">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="findAllTempPopulationsResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="findsAllResidentPopulation">
<soap:operation soapAction="" style="document" />
- <wsdl:input name="findsAllResidentPopulation">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="findsAllResidentPopulationResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="testSay">
<soap:operation soapAction="" style="document" />
- <wsdl:input name="testSay">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="testSayResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="PersonQueryService">
- <wsdl:port binding="tns:PersonQueryServiceSoapBinding"
name="PersonQueryPort">
<soap:address location="http://127.0.0.1:81/Proxypaltform/ws/
personQueryService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
上面是我的wsdl

jim ma

unread,
Jan 9, 2008, 8:50:25 AM1/9/08
to cxf...@googlegroups.com
PortType和message part以及引用的types在哪里?
这个方法对应的message part在哪里?
public List<ResidentPopulation> findsAllResidentPopulation(Stringsql);
你能描述一下你的步骤吗?

wlg

unread,
Jan 9, 2008, 9:56:44 AM1/9/08
to cxf-zh
我也觉得奇怪,在另外一个生成的wsdl中有portType的:
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://
spring.demo/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="HelloWorldImplService" targetNamespace="http://spring.demo/">
- <wsdl:types>
- <xsd:schema xmlns:tns="http://model.spring.demo"
attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://model.spring.demo" xmlns:xsd="http://
www.w3.org/2001/XMLSchema">
- <xsd:complexType name="Users">
- <xsd:sequence>
<xsd:element minOccurs="0" name="sex" nillable="true"
type="xsd:string" />
<xsd:element minOccurs="0" name="userId" nillable="true"
type="xsd:string" />
<xsd:element minOccurs="0" name="userName" nillable="true"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
- <xsd:complexType name="ArrayOfUsers">
- <xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Users"
nillable="true" type="tns:Users" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
- <xsd:schema xmlns:ns0="http://model.spring.demo"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://spring.demo/" xmlns:tns="http://spring.demo/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="finds" type="tns:finds" />
- <xsd:complexType name="finds">
<xsd:sequence />
</xsd:complexType>
<xsd:element name="findsResponse" type="tns:findsResponse" />
- <xsd:complexType name="findsResponse">
- <xsd:sequence>
<xsd:element name="return" type="ns0:ArrayOfUsers" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="sayHi" type="tns:sayHi" />
- <xsd:complexType name="sayHi">
- <xsd:sequence>
<xsd:element minOccurs="0" name="arg0" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="sayHiResponse" type="tns:sayHiResponse" />
- <xsd:complexType name="sayHiResponse">
- <xsd:sequence>
<xsd:element minOccurs="0" name="return" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="finds">
<wsdl:part element="tns:finds" name="parameters" />
</wsdl:message>
- <wsdl:message name="sayHiResponse">
<wsdl:part element="tns:sayHiResponse" name="parameters" />
</wsdl:message>
- <wsdl:message name="findsResponse">
<wsdl:part element="tns:findsResponse" name="parameters" />
</wsdl:message>
- <wsdl:message name="sayHi">
<wsdl:part element="tns:sayHi" name="parameters" />
</wsdl:message>
- <wsdl:portType name="HelloWorld">
- <wsdl:operation name="finds">
<wsdl:input message="tns:finds" name="finds" />
<wsdl:output message="tns:findsResponse" name="findsResponse" />
</wsdl:operation>
- <wsdl:operation name="sayHi">
<wsdl:input message="tns:sayHi" name="sayHi" />
<wsdl:output message="tns:sayHiResponse" name="sayHiResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="HelloWorldImplServiceSoapBinding"
type="tns:HelloWorld">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/
soap/http" />
- <wsdl:operation name="finds">
<soap:operation soapAction="" style="document" />
- <wsdl:input name="finds">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="findsResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="sayHi">
<soap:operation soapAction="" style="document" />
- <wsdl:input name="sayHi">
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output name="sayHiResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="HelloWorldImplService">
- <wsdl:port binding="tns:HelloWorldImplServiceSoapBinding"
name="HelloWorldImplPort">
<soap:address location="http://127.0.0.1:81/cxfspring/ws/
HelloWorld" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我在接口实现类中是进行了这样的描述
@WebService(portName = "PersonQueryPort", serviceName =
"PersonQueryService", targetNamespace = "http://proxy.org/
personquery", endpointInterface =
"org.proxyplatform.webservices.PersonQuery")
而上面这个实现类只进行了这样的描述:
@WebService(endpointInterface="demo.spring.HelloWorld")
不知是不是与这有关,我在接口包中使用了PersonQuery.aegis.xml文件进行描述
<?xml version="1.0" encoding="UTF-8"?>
<mappings>
<mapping>
<method name="findsAllResidentPopulation">
<return-type

componentType="org.proxyplatform.common.model.ResidentPopulation" /
>
</method>
</mapping>
<mapping>
<method name="findAllTempPopulations">
<return-type

componentType="org.proxyplatform.common.model.TempPopulation" />
</method>
</mapping>
</mappings>
不知是不是这样进行类型配置否?
public List<ResidentPopulation>
findsAllResidentPopulation(Stringsql);
这方法是这样进行的,由客户端调用并传一个String的参数过来,再由findsAllResidentPopulation调用本地的其他类的方法
来进行查询;

wlg

unread,
Jan 10, 2008, 3:18:53 AM1/10/08
to cxf-zh
各位兄弟请回答一下这个问题了,一样的配置,怎么产生了二种不一样的wsdl呢?

jim ma

unread,
Jan 10, 2008, 3:37:56 AM1/10/08
to cxf...@googlegroups.com
> @WebService(portName = "PersonQueryPort", serviceName =
> "PersonQueryService", targetNamespace = "http://proxy.org/
> personquery", endpointInterface =
> "org.proxyplatform.webservices.PersonQuery")
> 而上面这个实现类只进行了这样的描述:
> @WebService(endpointInterface="demo.spring.HelloWorld")
> 不知是不是与这有关,

是和这个有关系.

你服务器端是如何配置的?使用aegis databinding吗?


On Jan 10, 2008 4:18 PM, wlg <wuli...@hotmail.com> wrote:
> 各位兄弟请回答一下这个问题了,一样的配置,怎么产生了二种不一样的wsdl呢?
>
> >
>

wlg

unread,
Jan 10, 2008, 8:41:18 AM1/10/08
to cxf-zh
服务器端的配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:simple="http://cxf.apache.org/simple"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<bean id="logInbound"
class="org.apache.cxf.interceptor.LoggingInInterceptor" />
<bean id="logOutbound"
class="org.apache.cxf.interceptor.LoggingOutInterceptor" />

<bean id="jaxWsServiceFactoryBean"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
<property name="wrapped" value="true" />
<property name="dataBinding" ref="aegisBean" />
<property name="serviceConfigurations">
<list>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration" />
<bean

class="org.apache.cxf.aegis.databinding.AegisServiceConfiguration" />
<bean

class="org.apache.cxf.service.factory.DefaultServiceConfiguration" />
</list>
</property>
</bean>

<bean id="aegisBean"
class="org.apache.cxf.aegis.databinding.AegisDatabinding" />

<jaxws:endpoint id="personQueryServiceEndpoint"

implementorClass="org.proxyplatform.webservices.impl.PersonQueryImpl"
implementor="#personQuery"
address="/personQueryService">
<jaxws:serviceFactory>
<ref bean="jaxWsServiceFactoryBean" />
</jaxws:serviceFactory>
</jaxws:endpoint>

<jaxws:endpoint id="goodsQueryServiceEndpoint"
implementor="org.proxyplatform.webservices.impl.CommodityQueryImpl"
address="/goodsQueryService">
<jaxws:serviceFactory>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean" />
</jaxws:serviceFactory>
</jaxws:endpoint>

</beans>
另外在接口包中进行了如下的aegis配置:
<?xml version="1.0" encoding="UTF-8"?>
<mappings>
<mapping>
<method name="findsAllResidentPopulation">
<return-type

componentType="org.proxyplatform.common.model.ResidentPopulation" /
>
</method>
</mapping>
<mapping>
<method name="findAllTempPopulations">
<return-type

componentType="org.proxyplatform.common.model.TempPopulation" />
</method>
</mapping>
</mappings>
不知道这样对不对,还请jim ma解答,在此再次说谢谢了!

jim ma

unread,
Jan 10, 2008, 9:37:13 PM1/10/08
to cxf...@googlegroups.com
建议你用simple frontend 来配置aegis databinding.你可以参考一下samples/java_first_pojo

wlg

unread,
Jan 10, 2008, 11:18:23 PM1/10/08
to cxf-zh
好的,我再那样试下看
Reply all
Reply to author
Forward
0 new messages