추가 웹 서비스 매개변수를 지정한 후 해당 매개변수의 값을 전달하여 웹 서비스에 추가 제어 또는 감사 정보를 전달할 수 있습니다. 웹 서비스 전개 마법사에서 또는 프로젝트에 대한 등록 정보 창의 웹 서비스 페이지에서 매개변수 테이블의 매개변수를 지정하십시오.
전달된 값은 메시지가 요청하는 조작에 대해서만 적용됩니다. 전달된 값은 둘 이상의 메시지 또는 조작에 걸쳐있지 않습니다.
웹 서비스에 매개변수를 추가하려면 다음을 수행하십시오.
데이터 개발 프로젝트의 모든 웹 서비스에 대해 데이터베이스 연결 등록 정보 clientUser를 설정한다고 가정해 보겠습니다. 프로젝트 노드를 마우스 오른쪽 단추로 누른 후 등록 정보를 선택하십시오. 등록 정보 창에서 웹 서비스를 선택하십시오. 매개변수 테이블 옆의 웹 서비스 페이지에서 새로 작성을 눌러 테이블에 행을 추가하십시오. 새 행의 이름 컬럼에 connection.jcc.clientUser를 입력하십시오.
다음은 SOAP 헤더를 사용하여 Apache Axis2가 생성한 코드의 샘플입니다.
package myClientTest; import example.WebService2Stub; public class getEmployee { public static void main(String args[]) { try { // create the stub WebService2Stub stub = new WebService2Stub("http://localhost:8000/WebService2/services/WebService2"); // create the request elment for SOAP body WebService2Stub.GetEmployee empRequest = new WebService2Stub.GetEmployee(); // fill request with employee number empRequest.setEmpno("000130"); // create the Header for the request element WebService2Stub.ConnectionProperties properties = new WebService2Stub.ConnectionProperties(); WebService2Stub.ConnectionPropertiesType propertiesType = new WebService2Stub.ConnectionPropertiesType(); properties.setConnectionProperties(propertiesType); // fill the header with properties WebService2Stub.Property_type0 property1 = new WebService2Stub.Property_type0(); property1.setName("connection.jcc.clientUser"); property1.setValue("heathr"); propertiesType.addProperty(property1); WebService2Stub.GetEmployeeResponse response = stub.getEmployee(empRequest, properties); //... } catch (Exception e) { System.err.println(e.toString()); } } }
다음은 코드에 의해 생성되는 SOAP 요청입니다.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <ns1:connectionProperties xmlns:ns1="urn:example"> <property name="connection.jcc.clientUser" value="heathr"/> </ns1:connectionProperties> </soapenv:Header> <soapenv:Body> <ns1:getEmployee xmlns:ns1="urn:example"> <empno>000130</empno> </ns1:getEmployee> </soapenv:Body> </soapenv:Envelope>
다음 입력 메시지는 REST 유사 HTTP GET(url 인코딩됨)을 사용합니다.
GET /Project1WebService2/rest/WebService2/getEmployee?empno=000130&_connection.jcc.clientUser=heathr HTTP/1.1 User-Agent: Java/1.5.0 Host: localhost:8070 Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 Connection: keep-alive Content-type: application/x-www-form-urlencoded
요청의 결과 URL은 다음과 같습니다. 이 URL은 모든 HTTP 바인드에서 사용될 수 있습니다.
http://localhost:8080/Project1WebService2/rest/WebService2/getEmployee?empno=000130&_connection.jcc.clientUser=heathr