当我尝试通过使用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:无效的正整数:0 在 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) 在 org.apache.axis.client.Call.invoke(Call.java:2366) 在 org.apache.axis.client.Call.invoke(Call.java:1812)
线程“主”AxisFault faultCode 中的异常:{http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode:faultString:java.lang.NumberFormatException:无效的 positiveInteger:0 faultActor:在此处输入代码 faultNode:
faultDetail: {http://xml.apache.org/axis/} stackTrace:java.lang.NumberFormatException:无效的正整数:0 在 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) 在 org.apache.axis.client.Call.invoke(Call.java:2366) 在 org.apache.axis.client.Call.invoke(Call.java:1812)
我正在创建一个自定义 SOAP 标头,并且 SOAP 正文包含 MTOM 附件(以字节为单位的压缩 XML 内容)和一个 Id(Positive integer value)。我试图检查 Id 是否为正。