SOAP 웹 서비스 사용

클라이언트 애플리케이션은 의사결정 서비스 규칙 세트를 SOAP 웹 서비스로 호출할 수 있습니다.

시작하기 전에

클라이언트 애플리케이션은 클라우드 포털에 대한 인증 신임 정보를 전달해야 합니다 ( REST및 SOAP 호출에 대한 인증참조).

참고: Operational Decision Manager on Cloud 는 SOAP 1.1을 지원합니다. SOAP의 이후 버전을 지원하지 않습니다.

이 태스크에 대한 정보

클라이언트 애플리케이션이 의사결정 서비스 규칙 세트를 SOAP 웹 서비스로서 호출하기 위해서는 사용자가 규칙 세트 경로에 대해 생성된 WSDL(Web Services Description Language) 파일로부터 프록시 클래스를 작성해야 합니다. WSDL 파일의 형식은 이를 생성하는 언어와 독립적입니다.

프로시저

  1. 의사결정 서비스 규칙 세트의 WDSL 파일을 가져오십시오.
  2. WSDL 파일에서 프록시 클래스를 생성하십시오.
  3. 프록시 클래스를 사용하여 클라이언트 애플리케이션에서 규칙 세트를 호출하십시오.

Rule Execution Server에서 WSDL 파일을 가져오려면 다음을 수행하십시오.
  1. 규칙 세트를 Rule Execution Server에 배치하십시오.
  2. Rule Execution Server 콘솔에서 탐색기 탭으로 이동하십시오.
  3. Navigator 분할창에서 RuleApp을 클릭한 후 의사결정 서비스에 대응하는 규칙 세트를 클릭하십시오.
  4. 규칙 세트 보기에서 HTDS 설명 파일 검색을 클릭하십시오.
  5. 서비스 프로토콜 유형으로 SOAP을 선택하십시오.
  6. 최신 버전에 대해 WSDL 파일을 생성하려면 최신 규칙 세트 버전최신 RuleApp 버전을 선택하십시오.
  7. 다운로드를 클릭하십시오.
이 절차를 수행하려면 컴퓨터에 Eclipse IDE for Jakarta EE Developers가 설치되어 있어야 합니다. 여기에는 Java™ 애플리케이션에서 웹 서비스를 호출하기 위한 프록시 클래스를 생성하는 웹 도구 플랫폼이 포함되어 있습니다. Apache Axis로 프록시 클래스를 생성하려면 다음을 수행하십시오.
  1. Jakarta EE 개발자를 위한 Eclipse IDE 시작하고 프록시 클래스를 호스팅할 새 Java 프로젝트( 파일 > 새로 만들기 > Java 프로젝트 )를 만듭니다.
  2. 이 Java 프로젝트에 WSDL 파일을 복사하십시오.
  3. 파일 > 새로 작성 > 기타 > 웹 서비스 > 웹 서비스 클라이언트를 클릭하십시오.
  4. 웹 서비스 클라이언트 마법사에서 다음을 클릭하십시오.
  5. 서비스 정의에서 WSDL 파일을 찾아보십시오.
  6. 슬라이더를 이동하여 클라이언트 개발을 선택하십시오.
  7. 구성 아래에서 Apache Axis를 웹 서비스 런타임으로 선택했는지 확인한 후, 생성된 프록시 클래스를 호스팅할 클라이언트 프로젝트로 Java 프로젝트를 선택하십시오.
  8. 완료를 누르십시오.
다음 Java 코드 샘플은 MiniloanServiceRuleset 용 프록시 클래스를 가져오고 Java 애플리케이션에서 규칙 세트를 호출합니다.
import com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.MiniloanServiceMiniloanServiceRulesetBindingStub;
import com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.MiniloanServiceRulesetDecisionServiceProxy;
import com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.MiniloanServiceRulesetRequest;
import com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.MiniloanServiceRulesetResponse;
import com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.param.Borrower;
import com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.param.Loan;


public class DecisionServiceExecution {

	public static void main(String[] args) {
		
		// Replace <vhostname> with the name of the host of the Cloud portal
		// NB: endpointURI is defined in the location attribute of the WDSL file
		String endpointURI = "https://<vhostname>.bpm.ibmcloud.com/odm/dev/DecisionService/ws/MiniloanService/MiniloanServiceRuleset/v75";

		MiniloanServiceRulesetDecisionServiceProxy proxy = new MiniloanServiceRulesetDecisionServiceProxy(endpointURI);
		
		MiniloanServiceMiniloanServiceRulesetBindingStub stub = (MiniloanServiceMiniloanServiceRulesetBindingStub)proxy.getMiniloanServiceRulesetDecisionService_PortType();
	
		// Replace "loginID" with the functional ID of the service account you are using to authenticate with your tenant in the Cloud
		stub.setUsername("loginID");
		
		// Replace "password" with the password of the service account you are using to authenticate with your tenant in the Cloud
		stub.setPassword("password");
		
		// Set the borrower
		com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.Borrower borrower = 
				new com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.Borrower(
						"John", // name
						600, // credit score
						80000); // yearlyIncome
		
		Borrower borrowerParam = new Borrower(borrower);
		
		// Set the loan
		com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.Loan loan = 
				new com.ibm.www.rules.decisionservice.MiniloanService.MiniloanServiceRuleset.Loan(
						500000, // amount
						240, // duration
						0.05, // yearlyInterestRate
						0, // yearlyRepayment (to be computed by the decision service)
						true, // approved (set to true by default, to be computed by the decision engine),
						null); // messages (to be computed by the decision service)
		
		Loan loanParam = new Loan(loan);
		
		// Set the decision ID
		String decisionID = "1";
				
		MiniloanServiceRulesetRequest request = new MiniloanServiceRulesetRequest(decisionID, borrowerParam, loanParam);
		
		try {
			MiniloanServiceRulesetResponse response = proxy.miniloanServiceRuleset(request);
			System.out.println("Rules executed.");
			System.out.println("Approved: " + response.getLoan().getLoan().isApproved());
			System.out.println("Yearly interest rate: " + response.getLoan().getLoan().getYearlyInterestRate());
			System.out.println("Yearly repayment: " + response.getLoan().getLoan().getYearlyRepayment());
			String[] messages = response.getLoan().getLoan().getMessages();
			if (messages != null) {
				System.out.println("Messages: ");
				for (String message : messages) {
					System.out.println(message);
				}
			}
		}
		catch (Exception e) {
			throw new RuntimeException("An error occurred when invoking Decision Service at: "
										+ endpointURI, e);						
		}
	}

}