代码如下:
package com.peidw.foxconver.wsclient;import org.apache.axis.client.Call;
import org.apache.axis.client.Service;public class CaClient { public static void main(String[] args) {
try {
String endpoint = "http://xurrency.com/servidor_soap.php?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName("getValue");
call.addParameter("amount", org.apache.axis.encoding.XMLType.XSD_FLOAT,javax.xml.rpc.ParameterMode.IN);
call.addParameter("base", org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN);
call.addParameter("target", org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_FLOAT);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://xurrency.com/servidor_soap.php/getValue");
float result = (Float)call.invoke(new Object[]{444.4,"CNY","USD"});
System.out.println("result is "+result);
}catch (Exception e) {
e.printStackTrace();
}
}}
===============异常信息==========
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Bad envelope tag: definitions
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad envelope tag: definitions
at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
=============请大家帮调试一下,谢谢!
package com.peidw.foxconver.wsclient;import org.apache.axis.client.Call;
import org.apache.axis.client.Service;public class CaClient { public static void main(String[] args) {
try {
String endpoint = "http://xurrency.com/servidor_soap.php?wsdl";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName("getValue");
call.addParameter("amount", org.apache.axis.encoding.XMLType.XSD_FLOAT,javax.xml.rpc.ParameterMode.IN);
call.addParameter("base", org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN);
call.addParameter("target", org.apache.axis.encoding.XMLType.XSD_DATE,javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_FLOAT);
call.setUseSOAPAction(true);
call.setSOAPActionURI("http://xurrency.com/servidor_soap.php/getValue");
float result = (Float)call.invoke(new Object[]{444.4,"CNY","USD"});
System.out.println("result is "+result);
}catch (Exception e) {
e.printStackTrace();
}
}}
===============异常信息==========
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXException: Bad envelope tag: definitions
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Bad envelope tag: definitions
at org.apache.axis.message.EnvelopeBuilder.startElement(EnvelopeBuilder.java:71)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1048)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:533)
=============请大家帮调试一下,谢谢!
一般来说是字符问题~ 检查看看是不是有特殊字符~
但是不是因为wsdl协议版本的问题~
axis可以设置使用协议的版本吗,可以试一试~
你这样写下看看
String endpoint = "http://xurrency.com/servidor_soap.php";
去掉后面的 ?wsdl