import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
byte[] orderinfo=new byte[10];
orderinfo[0]=0x11;
orderinfo[1]=0x12;
orderinfo[2]=0x13;
orderinfo[3]=0x14;
orderinfo[4]=0x15;
orderinfo[5]=0x16;
orderinfo[6]=0x17;
String str = "";
//调用webservice
try {
// URL
String url = "http://192.168.10.154:10064/POPPayDemoService/Service.asmx";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(url));
// SoapRpcMethod:RequestNamespace
call.setOperationName(new QName("http://tempuri.org/su", "TestByte"));
call.addParameter("byteval", XMLType.XSD_BYTE,
javax.xml.rpc.ParameterMode.IN);
call.setUseSOAPAction(true);
// SoapRpcMethod:Action
call.setSOAPActionURI("http://tempuri.org/rpc7");
str = (String) call.invoke(new Object[]{orderinfo});
} catch (Exception e) {
System.out.println("asdf");
e.printStackTrace();
}
System.out.println(str);
}
}
请问为什么一调用就出错呢?
关于webservice地址及参数名和Action都是正确的,是不是用byte[]型传不过去啊?webservice那边的TestByte方法中的参数如果定义成String型,我这边也传string型,就正确,现在是byte按理来说也应该可以啊,因为webservice本身就是以字节流形式传输啊,不解,希望高手能给与解答,谢谢
以下错误信息
2008-7-4 17:43:33 org.apache.axis.client.Call invoke
严重: No returnType was specified to the Call object! You must call setReturnType() if you have called addParameter().
asdf
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: org.xml.sax.SAXParseException: Character reference "&#x0" is an invalid XML character.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: Character reference "&#x0" is an invalid XML character.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1411)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanCharReferenceValue(XMLScanner.java:1295)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3009)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:645)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:508)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)