当我尝试使用 Apache Axis 发送 SOAP 消息作为输入来使用Web服务时,我收到以下错误。
代码段:
Calendar calendar = Calendar.getInstance();
SimpleDateFormat simpledateformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
byte[] fileBytes = null;
fileBytes=getZipBytes(s); //get the zipped bytes
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
Date d=formatter.parse(formatter.format(calendar.getTime()));
UUID uuid = UUID.randomUUID();
String uid=trimUUID(uuid.toString());
String ETIN="11111";
String EFIN="111111";
String msgID= ETIN+getJulian7FromDate(d)+uid;
String timeStamp=simpledateformat.format(calendar.getTime());
WebServiceLocator fsetlocator=new WebServiceLocator();
SendSubmissions servicesoap=fsetlocator.getSendSubmissions(s4);
SOAPHeaderElement soapheaderelement_1 = new SOAPHeaderElement("http://xyz.org", "userHeader"); //Sample URL
SOAPElement node1 = soapheaderelement_1.addChildElement("Username");
node1.addTextNode("admin");
SOAPElement node2 = soapheaderelement_1.addChildElement("Password");
node2.addTextNode("pwd");
SOAPHeaderElement soapheaderelement_2 = new SOAPHeaderElement("http://www.abc.com/GatewayService", "msgHeader"); //Sample URL
SOAPElement node3 = soapheaderelement_2.addChildElement("message");
node3.addTextNode(msgID);
SOAPElement node4 = soapheaderelement_2.addChildElement("job");
node4.addTextNode("Submit");
SOAPElement node5 = soapheaderelement_2.addChildElement("Timestamp");
node5.addTextNode(timeStamp);
SOAPElement node8 = soapheaderelement_2.addChildElement("Process");
node8.addTextNode("T");
((Stub) servicesoap).setHeader(soapheaderelement_1);
((Stub) servicesoap).setHeader(soapheaderelement_2);
SubmissionDataListType submissiondatalisttype=new SubmissionDataListType();
String submissionsCount = getCount(s); // returns a count value
System.out.println("Count : "+submissionsCount);
submissiondatalisttype.setCount(new PositiveInteger(submissionsCount));
int cnt=Integer.parseInt(submissionsCount);
SubmissionDataListTypeSubmissionData submissiondata[] = new SubmissionDataListTypeSubmissionData[cnt];
for (int i=0 ; i<cnt ; i++){
submissiondata[i]=new SubmissionDataListTypeSubmissionData();
UUID uuid1 = UUID.randomUUID();
submissiondata[i].setSubmissionId ( EFIN + getJulian7FromDate(d) + trimUUID(uuid1.toString()));
Calendar calendar1 = Calendar.getInstance();
submissiondata[i].setElectronicPostmark(calendar1);
submissiondata[i].setCategory(CategoryType.StateWH);
}
submissiondatalisttype.setSubmissionData(submissiondata);
SubmissionDataListType subdatalist=new SubmissionDataListType(new PositiveInteger(submissionsCount),submissiondata);
SubmissionRecieptListType submissionreceiptlisttype =servicesoap.sendSubmissions(submissiondatalisttype, fileBytes);
SubmissionRecieptListTypeSubmissionReceipt receipt[] = submissionreceiptlisttype.getSubmissionReceipt();
FileOutputStream fileoutputstream = new FileOutputStream("Transmit.txt");
PrintStream printstream = new PrintStream(fileoutputstream);
for(int i=0; i<cnt;i++){
printstream.println(receipt[i].getSubmissionId());
}
printstream.close();
} catch(Exception exception)
{
System.out.println(exception.getMessage());
throw exception;
}
java.lang.NumberFormatException:无效的positiveInteger:0 at org.apache.axis.encoding.ser.SimpleDeserializer.onEndElement(SimpleDeserializer.java:176) 在 org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:502) 在 org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) 在 org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171) 在 org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141) 在 org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236) 在org.apache.axis.message.RPCElement.getParams(RPCElement.java:384) 在org.apache.axis.client.Call.invoke(Call.java:2467)at org.apache.axis.client.Call.invoke(Call.java:2366)at org.apache.axis.client.Call.invoke(Call.java:1812)
线程“main”中的异常AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode:faultString:java.lang.NumberFormatException:无效 positiveInteger:0 faultActor:输入代码herefaultNode:
faultDetail: {http://xml.apache.org/axis/}stackTrace:java.lang.NumberFormatException: 无效的positiveInteger:0 at org.apache.axis.encoding.ser.SimpleDeserializer.onEndElement(SimpleDeserializer.java:176) 在 org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:502) 在 org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087) 在 org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:171) 在 org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141) 在 org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236) 在org.apache.axis.message.RPCElement.getParams(RPCElement.java:384) 在org.apache.axis.client.Call.invoke(Call.java:2467)at org.apache.axis.client.Call.invoke(Call.java:2366)at org.apache.axis.client.Call.invoke(Call.java:1812)
我正在创建一个自定义SOAP标头,SOAP Body包含MTOM附件(以字节为单位的压缩XML内容)和一个Id(正整数值)。我试图检查Id是否为正。
答案 0 :(得分:0)
零不是正整数,它是无符号。正整数从一开始,然后从那里开始。