簡體   English   中英

如何查看為我的Java程序生成的SOAP請求和響應

[英]How to see the SOAP request and response generated for my Java program

通過遵循一個使用JAX-WS的示例,我已經創建了Java Web服務及其客戶端程序。

我的服務程序:

import javax.jws.WebService;
import javax.jws.WebMethod;
import java.util.Random;

@WebService
public interface RandService {
    @WebMethod
    public int next1();

    @WebMethod
    public int[] nextN(final int n);
}

/

import javax.jws.WebService;
import javax.jws.WebMethod;
import java.util.Random;

@WebService(endpointInterface = "rand2.RandService")
public class RandImpl implements RandService {
    private static final int maxRands = 16;

    @WebMethod
    public int next1() {
        return new Random().nextInt();
    }

    @WebMethod
    public int[] nextN(final int n) {
        final int k = (n > maxRands) ? maxRands : Math.abs(n);
        int[] rands = new int[k];
        Random r = new Random();
        for (int i = 0; i < k; i++)
            rands[i] = r.nextInt();
        return rands;
    }
}

這是我的客戶程序:

import client.RandServiceService;
import client.RandService;
import java.util.List;

public class RandClient {
    public static void main(String[] args) {
        // set-up
        RandServiceService service = new RandServiceService();
        RandService port = service.getRandServicePort();
        // sample calls
        System.out.println(port.next1());
        System.out.println();
        List<Integer> nums = port.nextN(4);
        for (Integer num : nums)
            System.out.println(num);
    }
}

程序運行良好,但是如何查看為程序內部生成的SOAP請求和SOAP響應? 請幫助我獲取這些詳細信息。

使用tcpmon ,盡管不再支持

SoapUI是ws測試的父親。 http://www.soapui.org

SoapUI OpenSource(免費)將向您顯示客戶端和服務器端的SOAP XML。 使用此工具,您將絕對從服務器端看到響應SOAP XML。 如果您只想試用zip存檔版本,請下載它。 (我通過設置JAVA_HOME並單擊SoapUI / bin / soapui.bat來啟動SoapUI的ZIP版本。

這是查看您的Web服務的快速入門。

1. Open SoapUI
 2. Create a Project

 3. Provide the path to your WSDL file. (If well-formed you will see the operations in your new project a tree control).

 4. Open the tree node to an operation and create a SoapUI request template
        a. Select the operation
                1) Right->Click "New Request" 
        b. Name the Request (new node for Request appears in tree)
 5. Run a test for your operation.
        a. Use the property editor below the tree
                1) Provide any arguments 
                2) Provide any authentication
        b. Right-Click on the Request
                1) "Show Request Editor"
  5. Ponder your SOAP request envelope XML (on left)
  6. Click on the run arrow
        a. Ponder your SOAP response (on right)

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM