Pages

Friday, May 30, 2008

Using Siebel WS in your ADF application

For our Siebel Unit I was making a demo which can search siebel accounts, displays a single account with the addresses and an insert page. The goal was to do this with the Siebel web service. This example gives an good example how to deal with complex web services, because the ADF Web Service Datacontrol only works with simple web services. You have a example on otn which use the ws datacontrol, but this only works on a simple web service method. When you want to search or create a new account you have to do more.
This is how it looks. The search page show all accounts ( calls SiebelAccountQueryByExample ). In this example you can search on Id and Name. You can also click on the Id then the account detail page is loaded.
When the detail page is loaded it calls SiebelAccountQueryById with the Id of the search page.

And the last page is the insert page

I did this by making a web service proxy on the local saved wsdl. To test this web service you have to do a lot.

nl.ordina.siebel.model.proxy.DefaultClient myPort = new nl.ordina.siebel.model.proxy.DefaultClient();
System.out.println("calling " + myPort.getEndpoint());
// Add your own code here
ListOfAccountInterfaceTopElmt inter = new ListOfAccountInterfaceTopElmt();
Account[] result = new Account[1];
Account acc = new Account();
acc.setAccountId("1-7SL");;
result[0]= acc;
inter.setListOfAccountInterface(result);
ListOfAccountInterfaceTopElmtHolder holder = new ListOfAccountInterfaceTopElmtHolder(inter);
myPort.siebelAccountQueryByExample(holder);
Account[] accs = holder.value.getListOfAccountInterface();
acc = accs[0];

This is to complex so I made it a bit easier. I created a java class where I call these ws methods and on this class I am making a datacontrol.

package nl.ordina.siebel;

import nl.ordina.siebel.model.proxy.DefaultClient;
import nl.ordina.siebel.model.proxy.holders.ListOfAccountInterfaceTopElmtHolder;
import nl.ordina.siebel.model.proxy.types.com.siebel.xml.account_interface.Account;
import nl.ordina.siebel.model.proxy.types.com.siebel.xml.account_interface.ListOfAccountInterfaceTopElmt;

public class SiebelActions {
public SiebelActions() {
}

public Account[] SearchAccount( Account msg ){
try {
DefaultClient myPort = new DefaultClient();
System.out.println("calling " + myPort.getEndpoint());
ListOfAccountInterfaceTopElmt inter = new ListOfAccountInterfaceTopElmt();
Account[] result = new Account[1];
result[0]= msg;
inter.setListOfAccountInterface(result);
ListOfAccountInterfaceTopElmtHolder holder = new ListOfAccountInterfaceTopElmtHolder(inter);
myPort.siebelAccountQueryByExample(holder);
return holder.value.getListOfAccountInterface();
}
catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

public Account[] GetAccount( String id ){
try {
DefaultClient myPort = new DefaultClient();
System.out.println("calling " + myPort.getEndpoint());
ListOfAccountInterfaceTopElmt result = myPort.siebelAccountQueryById(id);
return result.getListOfAccountInterface();
}
catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

public static void main(String[] args) {

SiebelActions sa = new SiebelActions();
Account acc = new Account();
acc.setAccountId("1-7SL");
Account[] result = sa.SearchAccount(acc);
acc = result[0];
System.out.println("account info "+acc.getAlias()+" name "+acc.getName());

result = sa.GetAccount("1-7SL");
acc = result[0];
System.out.println("account info 2 "+acc.getAlias()+" name 2 "+acc.getName());
}
}

I created an ADF Datacontrol on this class and use this datacontrol in the ADF JSF Pages. Because the input parameters of the ws methods are complex types, I had to create a bean with a method which returns the input parameter. In this bean I also added the search parameters field.
getAccount is used in the pagedef as input parameter on SiebelAccountQueryByExample.

package nl.ordina.siebel;

import nl.ordina.siebel.model.proxy.types.com.siebel.xml.account_interface.Account;

public class SiebelBean {

protected java.lang.String accountId;
protected java.lang.String showAccountId;
protected java.lang.String alias;
protected java.lang.String name;

public SiebelBean() {
}

public Account getAccount(){
Account acc = new Account();
acc.setAccountId(accountId);
acc.setAlias(alias);
acc.setName(name);
return acc;
}

public void setAccountId(String accountId) {
this.accountId = accountId;
}

public String getAccountId() {
return accountId;
}

public void setShowAccountId(String showAccountId) {
this.showAccountId = showAccountId;
}

public String getShowAccountId() {
return showAccountId;
}

public void setAlias(String alias) {
this.alias = alias;
}

public String getAlias() {
return alias;
}

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}
}

Here is a guide with all the steps I did. And here is the jdeveloper 10.1.3.3 project. To let it work on your own siebel 8 you only have to change the url of the ENDPOINT_ADDRESS_PROPERTY in the stub file created by the web service proxy and put in the right username / password else you can't insert new accounts.
_setProperty(ENDPOINT_ADDRESS_PROPERTY, "http://10.100.17.1/eai_nld/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&UserName=normani&Password=normani");

2 comments:

  1. Awesome work!

    I have a need to invoke a Siebel WS via JDeveloper and was attempting to do so via web proxy. However I keep getting an error

    WARNING: Unable to connect to URL: http://tfmmorrwwwa.na.jmsmucker.com/eai_enu/start.swe?SWEExtSource=SecureWebService&SWEExtCmd=Execute&UserName=jmseaiusr&Password=mb07cor4 due to java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: Connection refused: connect
    java.rmi.RemoteException: ; nested exception is:

    Caused by: HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: Connection refused: connect

    URL, account, and password are all correct.

    Any ideas??

    ReplyDelete
  2. I use http://10.100.17.1/eai_nld/start.swe?SWEExtSource=WebService&SWEExtCmd=Execute&UserName=normani&Password=normani");

    and you SWEExtSource=SecureWebService

    You have to some extra, maybe in this document it will give you some leads http://www-03.ibm.com/solutions/businesssolutions/oracle/doc/content/bin/Integrating_Siebel_Web_Services_Aug2006.pdf

    ReplyDelete