- 论坛徽章:
- 0
|
我用VB写了一个DLL文件,并把它封装成了WEBSERVICE,但是,调用的时候,出现了问题,JAVA客户端调用的时候
Generated fault:
Fault Code = SOAP-ENV:Client
Fault String = Deployment error in SOAP service 'urn:WebTest': class name 'hello.Name' could not be resolved: hello.Name
我想请教一下,这是为什么呢
JAVA客户端的程序:
package hello;
import java.net.URL;
import java.util.Vector;
import org.apache.soap.SOAPException;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.util.xml.QName;
public class Client2
{
public static void main(String[] args) throws Exception
{
if(args.length == 0)
{
System.err.println("Usage: java hello.Client [SOAP-router-URL] " ;
System.exit (1);
}
try
{
URL url = null;
String name = null;
if(args.length == 2)
{
url = new URL(args[0]);
name = args[1];
}
else
{
url = new URL("http://localhost:8081/soap/servlet/rpcrouter" ;
name = args[0];
}
// 构造调用对象
Call call = new Call();
call.setTargetObjectURI("urn:WebTest" ;
call.setMethodName("sayHello" ;
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// 创建类型映射注册器
SOAPMappingRegistry smr = new SOAPMappingRegistry();
BeanSerializer beanSer = new BeanSerializer();
// 映射类型
smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("urn:WebTest", "Hello.name" ,hello.Name.class, beanSer, beanSer);
call.setSOAPMappingRegistry(smr);
// 设置参数
Vector params = new Vector();
Name theName = new Name();
theName.setName(name);
params.addElement(new Parameter("name",hello.Name.class,theName, null));
call.setParams(params);
// 发出调用
Response resp = null;
try
{
resp = call.invoke(url, "" ;
}
catch( SOAPException e )
{
System.err.println("Caught SOAPException (" +
e.getFaultCode() + " : " + e.getMessage());
System.exit(-1);
}
// 检查应答
if( !resp.generatedFault() )
{
Parameter ret = resp.getReturnValue();
Object value = ret.getValue();
System.out.println(value);
}
else
{
Fault fault = resp.getFault();
System.err.println("Generated fault: " ;
System.out.println (" Fault Code = " + fault.getFaultCode());
System.out.println (" Fault String = " + fault.getFaultString());
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
这个生成WEBSERVICE时的XML文件,我是直接生成在TOMCAT下,没有用到AXIS
<!--Apache SOAP specific deployment descriptor (ie loads this service into Apache SOAP.-->
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:WebTest">
<isd:provider type="org.apache.soap.providers.com.RPCProvider" scope="Application" methods="sayHello">
<isd:java class="required not needed for COMProvider"/>
<isd ption key="progid" value="WebTest.Hello" />
</isd:provider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
<isd:mappings>
<isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns ="urn:WebTest" qname="x:hello.Name"
javaType="hello.Name"
java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
</isd:mappings>
</isd:service>
请大家指点一下,谢谢了 |
|