Hi guys,
i am new to web services, please help me out!!
Let me explain what i have to do and what i have done.
Task : I have to access a web method which looks like this
Sample method : basically i have to access a method which takes byte[] input and gives byte[] output (dynamically)
@WebMethod()
public byte[] sayGoodbye(byte[] input) {
byte[] temp = input;
System.out.println("The byte array is --> "+ temp.toString());
return temp;
}
Back ground info. on the web service
1. The web service is deployed in Web Logic Server
2. I need to access that method from
JBOSS SOA 5.0 AS
Things i have tried
1. Create stud, skeleton using clinetGen and access the method from a standalone
java class...it is working, but i am not allowed to proceed in this way, as this way we are dependent on weblogic.jar and webservices.jar of Web Logic.
2. So i used WSimport to create the stud, skeleton and wrote a standalone java class to access the method, i am getting the error : Cannot create service instance, that particular service is not present in WSDL. (but it is present in wsdl, i am able to see it in WSDL)
Can anyone tell me why i am getting error like this???
3. I also tried to create a
SOAP message and access it, in this way i am
not able to add byte[] data to the SOAP message. Can we actually do it in any way???
/** Create a service and add at least one port to it. **/
Service service = Service.create(serviceName);
service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
/** Create a Dispatch instance from a service.**/
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
/** Create SOAPMessage request. **/
// compose a request message
MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
/** Create a message. This example works with the SOAPPART. **/
SOAPMessage request = mf.createMessage();
SOAPPart part = request.getSOAPPart();
/** Obtain the SOAPEnvelope and header and body elements. **/
SOAPEnvelope env = part.getEnvelope();
SOAPHeader header = env.getHeader();
SOAPBody body = env.getBody();
/** Construct the message payload. **/
SOAPElement operation = body.addChildElement("sayGoddbye", "ns1", "http://webservices.samples.jboss.org/"); // sayGoodbye is the web method
SOAPElement value = operation.addChildElement("arg0");
value.addTextNode(finalstr); // 'finalstr' is a String, here i need to add a byte[], how do i do that???
request.saveChanges();
/** Invoke the service endpoint. **/
SOAPMessage responseMessage = dispatch.invoke(request);
I want to know, how to access a web method which takes in byte[] and gives byte[] , dynamically???
Is there any other way to access this web method using JAX WS and not JAX RPC???
Thank you guys