2017-03-06 11 views
0
  List<String> assignedGroups = new ArrayList<>(); 
      assignedGroups.add("Group1"); 
      assignedGroups.add("Group2"); 
      assignedGroups.add("Group3"); 
      assignedGroups.add("Group4"); 
      assignedGroups.forEach(assignedGroup -> { 

       System.out.println(""); 
       System.out.println("Retrieving tickets from " + assignedGroup + " ..."); 
       System.out.println(""); 

       /** 
       * @param args 
       * Cloud Server Deployment - Create server in CIA in Active state 
       */ 
       // Create SOAP Response 
       String qualification = "'Priority' == \"Critical\" AND 'Assigned Group' = \""+ assignedGroup + "\""; 
       SOAPMessage soapResponse = null; 
       try { 
        soapResponse = soapConnection.call(createSOAPRequest(qualification), url); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 
       try { 
        if (soapResponse != null) { 
         soapResponse.writeTo(System.out); 
         System.out.println("Giant Spaghetti Monster!"); 
        } 
       } catch (SOAPException | IOException e) { 
        e.printStackTrace(); 
       } 

       // Print the SOAP Response 
       try { 
        printSOAPResponse(soapResponse, soapConnection); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 

      }); 

後にリスト反復に進みます。代わりに、例外を固定するSOAP応答を取得しようとしているとき時々私はNullPointerExceptionが取得例外

<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>soapenv:Server.userException</faultcode><faultstring>ERROR (302): Entry does not exist in database; </faultstring><detail><ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">WEBDKBA866</ns1:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope> 
java.lang.NullPointerException 
    at src.RemedySOAPWebService.printSOAPResponse(RemedySOAPWebService.java:218) 
    at src.RemedySOAPWebService.lambda$main$0(RemedySOAPWebService.java:78) 
    at java.util.ArrayList.forEach(ArrayList.java:1249) 
    at src.RemedySOAPWebService.main(RemedySOAPWebService.java:49) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 

は今、それを無視して上に移動する方法がありますリスト内の次のグループに移動しますか?

例えば、NPEはGroup3で発生します。スクリプトがクラッシュするのではなく、Group4に移動できますか?私はGiant Spaghetti Monsterを印刷しました。ここでNPEが発生します。これは可能ですか?

+0

[例外後にループを続ける](http://stackoverflow.com/questions/25101575/continue-a-while-loop-after-exception) – ForInfinity

+0

の行を折り返すだけです。 try catchブロックで例外を発生させ、あなたは良いことですが、nullpointerまたは空の配列を持つ状況を処理するようにしてください。 – Mehdi

答えて

1

あなたはSOAPExceptionをキャッチしています。 IOException。例外もキャッチします。

関連する問題