ysahuly wrote:
Hi buddies,
I need to send a Soap Message as String to invoke the webservice using local
transport for that i have followed the below procedure...Correct me if i
done anything wrong....
1. Created a class called DirectServiceIn which have the below content
public void callService() {
String messageXML = "<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soapenvelope/">
<soap:Body>
<ns1:getEmployeeInfo xmlns:ns1="ns1">
<employeeId>1</employeeId>
</ns1:getEmployeeInfo>
</soap:Body>
</soap:Envelope>";
try {
LocalTransportFactory obj =
(LocalTransportFactory) SpringUtilities.getInstance()
.getBeanFactory()
.getBean(LocalTransportFactory.class.getName());
EndpointInfo ei = new EndpointInfo();
Here is not correct.
You should build ei from your jaxws:endpoint configuration, which means
get chance to build servciemodel from your SEI class, then the response
message can be recognized.
ei.setAddress("local://message");
Destination destination = obj.getDestination(ei);
MessageImpl m = new MessageImpl();
ByteArrayInputStream bis = new
ByteArrayInputStream(messageXML.getBytes());
m.setContent(InputStream.class, bis);
m.setDestination(destination);
ExchangeImpl exchangeImpl = new ExchangeImpl();
exchangeImpl.setConduit(obj.getConduit(ei));
exchangeImpl.setInMessage(m);
exchangeImpl.setDestination(destination);
m.setExchange(exchangeImpl);
SoapMessage sm = new SoapMessage(m);
destination.getMessageObserver().onMessage(sm);
} catch (Throwable t) {
}
}
2. Wrote the below configuration file :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:simple="http://cxf.apache.org/simple"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/simple
http://cxf.apache.org/schemas/simple.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-local.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<jaxws:endpoint name="employeeService"
address="local://message"
implementor="com.mckesson.cxf.sample.async.service.EmployeeServiceImpl">
</jaxws:endpoint>
<jaxws:endpoint id="employee"
implementor="com.mckesson.cxf.sample.async.service.EmployeeServiceImpl"
address="/employee">
</jaxws:endpoint>
3.EmployeeService interface and EmployeeServiceImpl class which have the
business logic...
4. While doing this part destination.getMessageObserver().onMessage(sm)
service gets invoked and return the Employee object but with this not
stopped...
It tryingy to do call an another inInterceptor and caused the below
exception...
org.apache.cxf.interceptor.Fault: Message part {ns1}getEmployeeInfoResponse
was not recognized. (Does it exis
at
org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:179)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
at
org.apache.cxf.transport.local.LocalConduit$1$1.run(LocalConduit.java:132)
at java.lang.Thread.run(Thread.java:595)
00:36:15,515 ERROR [STDERR] Dec 19, 2008 12:36:15 AM
org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:260)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
at
org.apache.cxf.transport.local.LocalConduit$1$1.run(LocalConduit.java:132)
Any idea about this otherwise any other solution to hit the server with the
provided soap message part as string....