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. 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: Invalid 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. 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 が正かどうかを確認しようとしました。