I’m writing some Java code which needs to extract data (a security token) from the SOAP Header (and subsequently put it back in the header whenver a call is made).
I’ve figured I can use the javax.xml libraries and I am trying to get a handle on the SOAPMessageContext however all the example code I find assumes that context has been set. I can substitute context for agentContext and it compiles however I get the following error:
“java.lang.ClassCastException: lotus.domino.local.AgentContext incompatible with javax.xml.rpc.handler.soap.SOAPMessageContext”
Any help would be appreciated. Here is my code so far:
CODE*****************
import java.net.URL;
import javax.xml.rpc.handler.*;
import javax.xml.namespace.QName;
import javax.xml.rpc.handler.soap.SOAPMessageContext;
import javax.xml.rpc.JAXRPCException;
import javax.xml.rpc.NamespaceConstants;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPBody;
import org.w3c.dom.*;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import com.prosight.wsdl._5_0.psPortfoliosItem.*;
import com.prosight.wsdl._5_0.psPortfoliosSecurity.*;
import com.prosight.wsdl.*;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
//The first thing to do is login String userName = "webservices";
String userPassword = "webservices";
URL securityURL = new URL("http://shocnt148/ProSightWS/psPortfoliosSecurity.asmx");
PsPortfoliosSecurityLocator securitylocator = new PsPortfoliosSecurityLocator();
PsPortfoliosSecuritySoap secSoap = securitylocator.getPsPortfoliosSecuritySoap(securityURL);
System.out.println("xx");
secSoap.login(userName, userPassword, 60);
// MessageContext msgContext;
// get the soap header
SOAPMessageContext smc = (SOAPMessageContext) context;
//******* the above line is the headache, eclipse considers it an undeclared variable. If I use agent context it gives an error at runtime.
SOAPMessage message = smc.getMessage();
System.out.println(message);
//Instantiate an itemLocator
URL itemURL = new URL("http://shocnt148/ProSightWS/psPortfoliosItem.asmx");
PsPortfoliosItemLocator Itemlocator = new PsPortfoliosItemLocator();
PsPortfoliosItemSoap itemSoap = Itemlocator.getPsPortfoliosItemSoap(itemURL);
System.out.println("ya" );
// PsPortfoliosItem ItemObj = new PsPortfoliosItem();
//secSoap.login(userName, userPassword, 60); //moved this here to see if we need to login after all objects have been created, can't see why it should be that way
itemSoap.setCredentials(userName, userPassword);
System.out.println(itemSoap.getEndpoint());
System.out.println(itemSoap.getIDByName("", "Var 1"));
} catch(Exception e) {
e.printStackTrace();
}
}
}