Hi,
I am accessing a .net webservice using XFIRE client. Code is below.
When I have SoapActionHandler i am getting an exception saying
"org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested
exception is org.codehaus.xfire.fault.XFireFault: Fault:
java.lang.NullPointerException"
When i dont use it i am getting "org.codehaus.xfire.XFireRuntimeException:
Could not invoke service.. Nested exception is
org.codehaus.xfire.fault.XFireFault: Server did not recognize the value of
HTTP Header SOAPAction: ."
My code is here below with stacktrace.
public class BookClientSign
{
public static final String SERVICE_NAMESPACE = "http://tempuri.org/";
public static final String
SERVICE_URL="http://localhost:222/ServeJava/Service1.asmx";
protected void configureOutProperties(Properties properties)
{
properties.setProperty(WSHandlerConstants.ACTION,WSHandlerConstants.SIGNATURE);
properties.setProperty(WSHandlerConstants.USER, "wse2qsclient");
properties.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS,
org.codehaus.xfire.demo.PasswordHandler.class.getName());
properties.setProperty(WSHandlerConstants.SIG_PROP_FILE,"org/codehaus/xfire/client/outsecurity_sign.properties");
properties.setProperty(WSHandlerConstants.SIG_KEY_ID,"DirectReference" );
properties.setProperty(WSHandlerConstants.TIMESTAMP,"true");
}
public void executeClient(String serviceName)
throws MalformedURLException
{
System.out.print("Running client : "+getName()+"\n");
Service serviceModel = new
ObjectServiceFactory().create(Service1Soap.class,"Service1",
SERVICE_NAMESPACE,
null);
System.out.println(serviceModel.toString());
Service1Soap service = (Service1Soap) new
XFireProxyFactory().create(serviceModel, SERVICE_URL);
Client client = ((XFireProxy)
Proxy.getInvocationHandler(service)).getClient();
client.addOutHandler(new DOMOutHandler());
Properties properties = new Properties();
configureOutProperties(properties);
client.addOutHandler(new SoapActionHandler());
client.addOutHandler(new WSS4JOutHandler(properties));
try{
String b = service.helloWorld();
System.out.print("Response is " + b);
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
throws MalformedURLException
{
new BookClientSign().executeClient("BookServiceSign");
}
}
public class SoapActionHandler extends AbstractHandler {
public void invoke(MessageContext msgContext) {
Service service = msgContext.getService();
if (service != null)
{
String action = "http://tempuri.org/";
msgContext.getOutMessage().setProperty(SoapConstants.SOAP_ACTION, action);
}
}
}
When use client.addOutHandler(new SoapActionHandler());
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested
exception is org.codehaus.xfire.fault.XFireFault: Fault:
java.lang.NullPointerException
org.codehaus.xfire.fault.XFireFault: Fault: java.lang.NullPointerException
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
at org.codehaus.xfire.client.Client.invoke(Client.java:335)
at
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy5.helloWorld(Unknown Source)
at
org.codehaus.xfire.client.BookClient.executeClient(BookClient.java:72)
at org.codehaus.xfire.client.BookClientSign.main(BookClientSign.java:45)
Caused by: java.lang.NullPointerException
at
org.codehaus.xfire.handler.HandlerOrderer.insertHandler(HandlerOrderer.java:33)
at
org.codehaus.xfire.handler.HandlerPipeline.addHandler(HandlerPipeline.java:75)
at
org.codehaus.xfire.handler.HandlerPipeline.addHandlers(HandlerPipeline.java:57)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:68)
... 6 more
when i dont use client.addOutHandler(new SoapActionHandler()) the stack
trace is
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested
exception is org.codehaus.xfire.fault.XFireFault: Server did not recognize
the value of HTTP Header SOAPAction: .
org.codehaus.xfire.fault.XFireFault: Server did not recognize the value of
HTTP Header SOAPAction: .
at
org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
at
org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
at
org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
at
org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Client.onReceive(Client.java:382)
at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
at
org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
at org.codehaus.xfire.client.Client.invoke(Client.java:335)
at
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy5.helloWorld(Unknown Source)
at
org.codehaus.xfire.client.BookClient.executeClient(BookClient.java:72)
at org.codehaus.xfire.client.BookClientSign.main(BookClientSign.java:45)
Kindly help me
Regards,
Prasanna
--
View this message in context:
http://www.nabble.com/Could-not-invoke-service..-Nested-exception-is-org.codehaus.xfire.fault.XFireFault%3A-Fault%3A-java.lang.NullPointerException-tf3232226.html#a8980776
Sent from the XFire - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email