2015-04-25 25 views

回答

5

謝里夫,

下面是一個命令行示例中,我寫了一個很久以前。以下假設在此示例中使用:與演示 應用數據庫安裝

  1. 客戶端應用程序訪問Acumatica ERP實例。 Web服務WSDL定義文件被導入 和在AR303000包中生成的代理類。
  2. Web服務WSDL定義文件被導入,代理類 在AR303000包中生成。

    private static String getCookie(BindingProvider port) { 
         Map<String, ?> headers = (Map<String, ?>) port.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS); 
    
         StringBuilder sb = new StringBuilder(); 
    
         List<String> cookie = (List<String>) headers.get("Set-Cookie"); 
    
         for (String c : cookie) { 
           int idx = c.indexOf(";"); 
           if (idx != -1) { 
             sb.append(c.substring(0, idx)); 
           } else 
             sb.append(c); 
           sb.append("; "); 
         } 
    
         return sb.toString(); 
    } 
    
    private static void setCookie(BindingProvider port, String value) { 
         port.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, Collections.singletonMap("Cookie", Collections.singletonList(value))); 
    } 
    
    public static void main(String[] args) { 
    
        Screen service = new Screen(); 
        ScreenSoap screen = service.getScreenSoap(); 
    
        LoginResult lres = screen.login("admin", "123"); 
    
        String cookie = getCookie((BindingProvider) screen); 
        setCookie((BindingProvider) screen, cookie); 
    
        Content content = screen.getSchema();  
    
        ArrayOfCommand commands = new ArrayOfCommand(); 
        commands.getCommand().add(content.getCustomerSummary().getServiceCommands().getEveryCustomerID()); 
        commands.getCommand().add(content.getCustomerSummary().getCustomerName()); 
        commands.getCommand().add(content.getGeneralInfoMainAddress().getCity()); 
    
        ArrayOfArrayOfString result = screen.export(commands, null, 0, true, true); 
        List<ArrayOfString> lines = result.getArrayOfString(); 
    
        for (int i = 0; i < lines.size(); i++) 
        { 
         List<String> currentLine = lines.get(i).getString(); 
         System.out.printf("%s (%s)\n", currentLine.get(0), currentLine.get(1)); 
        }  
        } 
    } 
    
+0

喜加布裏埃爾,精彩......謝謝你這麼多 – SharifA

+0

[這裏是我的老文章] [1] [1]:http://forum.acumatica.com/forum/ acumatica轉銷商和獨立軟件開發商社區/顯影和定製/ 740-API如何做創建的API項目和使用的,它與 - C-PHP-java的?p = 3391#post3391 – srodionov