Hello: I found some code on the Internet about adding the handler to my client. Here is what I did:
List<HandlerInfo> handlerChain = new ArrayList<HandlerInfo>();
HandlerInfo handlerInfo = new
HandlerInfo(AuthenticationHandler.class,null,null);
handlerChain.add(handlerInfo);
AdminServiceLocator locator = new AdminServiceLocator();
HandlerRegistry registry = locator.getHandlerRegistry();
QName serviceName = new
QName("http://api.channeladvisor.com/webservices/", "AdminServiceSoap");
registry.setHandlerChain(serviceName, handlerChain);
locator.getAdminServiceSoap().ping();
When I run this, I get this exception:
Unable to create handler of type class
com.jammconsulting.channelAdvisor.AuthenticationHandler
I am attaching the AuthenticationHandler class, everything looks correct
to me.
Any ideas why this is not working?
Thanks,
Neil
--
Neil Aggarwal, (972)834-1565, http://UnmeteredVPS.net/centos
Virtual private server with CentOS 5.5 preinstalled
Unmetered bandwidth = no overage charges
-----Original Message-----
From: Neil Aggarwal [mailto:[email protected]]
Sent: Tuesday, May 10, 2011 11:43 PM
To: [email protected]
Subject: [Axis1.4] Problems with ChannelAdvisor WSDL
Hello:
I am trying to process the ChannelAdvisor WSDL for their
AdminService. They have posted their WSDL here:
http://developer.channeladvisor.com/display/cadn/Admin+Service
I used WSDL2Java to create the client classes, but
it does not generate a class for APICredentials.
If I add the --all switch, it generates an APICredentials
class but then there is no way to attach the credentials
to the service call.
Here is a page with the desired XML request:
http://developer.channeladvisor.com/display/cadn/RequestAccess
Here is a page with sample code in C# and other languages:
http://developer.channeladvisor.com/display/cadn/Ping+Examples
Unfortunately, none of their example include Java and their
support staff has no knowledge of Java or Axis so I am left
on my own to figure this out.
I have found some postings on the Internet with people having
similar problems as I am. They point to using a BasicHandler
to manually insert the APICredentials into the SOAP header.
I found some code for a handler:
public class AuthenticationHandler extends BasicHandler {
/** Invoke this hander */
public void invoke(MessageContext context) throws AxisFault {
try {
SOAPMessageContext smc = (SOAPMessageContext) context;
SOAPMessage message = smc.getMessage();
QName APICredentialsName = new
QName("http://api.channeladvisor.com/webservices/","APICredentials");
QName DeveloperKeyName = new
QName("http://api.channeladvisor.com/webservices/","DeveloperKey");
QName PasswordName = new
QName("http://api.channeladvisor.com/webservices/", "Password");
SOAPHeader header = message.getSOAPHeader();
SOAPHeaderElement cred = new SOAPHeaderElement(APICredentialsName);
SOAPHeaderElement key = new SOAPHeaderElement(DeveloperKeyName);
key.setObjectValue("DevKey");
SOAPHeaderElement pw = new SOAPHeaderElement(PasswordName);
pw.setObjectValue("Pass");
cred.addChildElement(key);
cred.addChildElement(pw);
header.appendChild(cred);
} catch (Exception e) {
throw new AxisFault("Error during authentication", e);
}
}
But, I am not sure how to use it to insert the credentials into
the service call.
If anyone has some insight, I would appreciate it.
Thank you,
Neil
--
Neil Aggarwal, (972)834-1565, http://UnmeteredVPS.net/centos
Virtual private server with CentOS 5.5 preinstalled
Unmetered bandwidth = no overage charges
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
AuthenticationHandler.java
Description: Binary data
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
