最近做一个项目,使用了webservice,但是这个接口是别人提供的并且没有完成,但是wsdl给提供了.
想使用soapui的mockservice功能模拟一个webservice.
首先用axis做了一个webservice,用以下代码进行测试ok,但访问soapui做的mockservice失败,
java webclient代码如下:
java code?123456789101112131415161718192021222324252627 // string endpoint = "http://localhost:8080/axis/hello.jws?wsdl"; string endpoint = "http://localhost:8088/axis/hello.jws?wsdl";
service service = new service();
call call = (call) service.createcall();
call.settargetendpointaddress(endpoint);
call.setoperationname("hello");
call.setsoapversion(soapconstants.soap11_constants);
call.addparameter("name", org.apache.axis.encoding.xmltype.xsd_string, javax.xml.rpc.parametermode.in); // call.addparameter("tocurrency", org.apache.axis.encoding.xmltype.xsd_string, // // javax.xml.rpc.parametermode.in);
call.setreturntype(org.apache.axis.encoding.xmltype.xsd_string);
object result = call.invoke(new object[]{"jpy"});
system.out.println("result is "+result.tostring());
soapui的http log如下:
sun aug 26 23:18:36 jst 2012:debug:hellosoapbinding mockservice was unable to dispatch mock request
com.eviware.soapui.impl.wsdl.mock.dispatchexception: missing operation for soapaction [] and body element [hello] with soap version [soap 1.1]
at com.eviware.soapui.impl.wsdl.support.soap.soaputils.findoperationforrequest(soaputils.java:353)
at com.eviware.soapui.impl.wsdl.mock.wsdlmockrunner.dispatchpostrequest(wsdlmockrunner.java:260)
at com.eviware.soapui.impl.wsdl.mock.wsdlmockrunner.dispatchrequest(wsdlmockrunner.java:383)
at com.eviware.soapui.monitor.jettymockengine$serverhandler.handle(jettymockengine.java:701)
at org.mortbay.jetty.handler.handlercollection.handle(handlercollection.java:114)
at org.mortbay.jetty.handler.handlerwrapper.handle(handlerwrapper.java:152)
at org.mortbay.jetty.server.handle(server.java:326)
at org.mortbay.jetty.httpconnection.handlerequest(httpconnection.java:542)
at org.mortbay.jetty.httpconnection$requesthandler.content(httpconnection.java:938)
at org.mortbay.jetty.httpparser.parsenext(httpparser.java:755)
at org.mortbay.jetty.httpparser.parseavailable(httpparser.java:218)
at org.mortbay.jetty.httpconnection.handle(httpconnection.java:404)
at org.mortbay.io.nio.selectchannelendpoint.run(selectchannelendpoint.java:409)
at org.mortbay.thread.queuedthreadpool$poolthread.run(queuedthreadpool.java:582)
sun aug 26 23:18:36 jst 2012:error:an error occured [missing operation for soapaction [] and body element [hello] with soap version [soap 1.1]], see error log for details
java的错误代码如下:
- unable to find required classes (javax.activation.datahandler and javax.mail.internet.mimemultipart). attachment support is disabled.
axisfault
faultcode: {http://xml.apache.org/axis/}http
faultsubcode:
faultstring: (500)internal server error
faultactor:
faultnode:
faultdetail:
{}:return code: 500
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:body>
<soapenv:fault>
<faultcode>server</faultcode>
<faultstring>missing operation for soapaction [] and body element [hello] with soap version [soap 1.1]</faultstring>
</soapenv:fault>
</soapenv:body>
</soapenv:envelope>
{http://xml.apache.org/axis/}httperrorcode:500
(500)internal server error
at org.apache.axis.transport.http.httpsender.readfromsocket(httpsender.java:744)
at org.apache.axis.transport.http.httpsender.invoke(httpsender.java:144)
at org.apache.axis.strategies.invocationstrategy.visit(invocationstrategy.java:32)
at org.apache.axis.simplechain.dovisiting(simplechain.java:118)
at org.apache.axis.simplechain.invoke(simplechain.java:83)
at org.apache.axis.client.axisclient.invoke(axisclient.java:165)
at org.apache.axis.client.call.invokeengine(call.java:2784)
at org.apache.axis.client.call.invoke(call.java:2767)
at org.apache.axis.client.call.invoke(call.java:2443)
at org.apache.axis.client.call.invoke(call.java:2366)
at org.apache.axis.client.call.invoke(call.java:1812)
at webserviceclient.main(webserviceclient.java:51)
用java访问axis的webservice的ok结果如下:
result is hello jpy
最新内容请见作者的github页:http://qaseven.github.io/