Avinash Annamaneni

Greenhorn
+ Follow
since Nov 21, 2010
Avinash likes ...
Eclipse IDE Java
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Avinash Annamaneni

Hi Naren,

I have solved the issue...thank you

Problem - I want to know, how to access a web method which takes in byte[] and gives byte[] , dynamically???

Solution - You can do this in the following way
- encoding the byte array to base64Binary String
- adding the String to the SOAP message (Element), using the .addTextNode(); method
- then decode the output byte[] to normal byte[]
and get the value from the byte array.

Encoding the Byte[] to base64Binary



Decoding the output



Viewing data from byte[] output

13 years ago
Hi all,

I have a problem in accessing a web service, please help me out

Task : I have a WSDL with me, which i am able to open and see it (ie. i have network access) , i have to call the methods in the wsdl

What i did : I used that wsdl to create a client in Jboss Developer studio 3.0 (ie. create a Dynamic web project then right click on it and select create web service client,give wsdl and then client it gets created)

But when i am trying to run the client it says

Exception in thread "main" Cannot create Service instance, service {urn:ucsvitriawebservice:Vitriawebservice}ucsvitriawebservice not found in the WSDL http://localhost:8080/ucsvitriawebservice/Vitriawebservice?wsdl
at com.sun.xml.internal.ws.client.ServiceContextBuilder.build(Unknown Source)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(Unknown Source)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(Unknown Source)
at javax.xml.ws.Service.<init>(Unknown Source)
at vitriawebservice.ucsvitriawebservice.Ucsvitriawebservice.<init>(Ucsvitriawebservice.java:45)
at vitriawebservice.ucsvitriawebservice.clientsample.ClientSample.main(ClientSample.java:10)


but the service is present in wsdl...

Here is the wsdl file



I tried creating the client using ClientGen and then tried to acces the method then it is working, but in this way we are dependent on weblogic.jar and webservices.jar (ie. these jar's must be in the classpath)

I have to acces the web service from within the JBOSS server so i am not allowed to proceed in the above way.

Help me out please...

Thank you

13 years ago
Hi Naren,

Silly me...i changed the name of the opertaion,

now i am able to reach it but i am not getting the response back

and i am getting the following error in the clinet side:

org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkQName(Unknown Source)
at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.setName(Unknown Source)
at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.<init>(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.<init>(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementFactory.createElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl.createElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.createElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addChildElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addChildElement(Unknown Source)
at com.hex.test.DynamicUPMCall.main(DynamicUPMCall.java:182)


The method i have mentioned in my 1st post is the actual method i am trying to reach...the temp.toString is getting printed in the server, and no error in the server...but no response in the client.

Thank you
13 years ago
Hi Naren,

The wsdl i have sent to you is not for this method...the problem i am getting with that wsdl's client is Cannot create service

The WSDl for the sayGoodbye operation is this

WSDL

<definitions name='HelloWorldService' targetNamespace='http://webservices.samples.jboss.org/' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservices.samples.jboss.org/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<types>
<xs:schema targetNamespace='http://webservices.samples.jboss.org/' version='1.0' xmlns:tns='http://webservices.samples.jboss.org/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:element name='sayGoodbye' type='tns:sayGoodbye'/>
<xs:element name='sayGoodbyeResponse' type='tns:sayGoodbyeResponse'/>
<xs:element name='sayHello' type='tns:sayHello'/>
<xs:element name='sayHelloResponse' type='tns:sayHelloResponse'/>
<xs:complexType name='sayHello'>
<xs:sequence>
<xs:element minOccurs='0' name='arg0' type='xs:string'/>
</xs:sequence>
</xs:complexType>
<xs:complexType name='sayHelloResponse'>
<xs:sequence>
<xs:element minOccurs='0' name='return' type='xs:string'/>
</xs:sequence>
</xs:complexType>
<xs:complexType name='sayGoodbye'>
<xs:sequence>
<xs:element minOccurs='0' name='arg0' type='xs:base64Binary'/>
</xs:sequence>
</xs:complexType>
<xs:complexType name='sayGoodbyeResponse'>
<xs:sequence>
<xs:element minOccurs='0' name='return' type='xs:base64Binary'/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name='HelloWorld_sayHello'>
<part element='tns:sayHello' name='sayHello'></part>
</message>
<message name='HelloWorld_sayGoodbye'>
<part element='tns:sayGoodbye' name='sayGoodbye'></part>
</message>
<message name='HelloWorld_sayHelloResponse'>
<part element='tns:sayHelloResponse' name='sayHelloResponse'></part>
</message>
<message name='HelloWorld_sayGoodbyeResponse'>
<part element='tns:sayGoodbyeResponse' name='sayGoodbyeResponse'></part>
</message>
<portType name='HelloWorld'>
<operation name='sayGoodbye' parameterOrder='sayGoodbye'>
<input message='tns:HelloWorld_sayGoodbye'></input>
<output message='tns:HelloWorld_sayGoodbyeResponse'></output>
</operation>
<operation name='sayHello' parameterOrder='sayHello'>
<input message='tns:HelloWorld_sayHello'></input>
<output message='tns:HelloWorld_sayHelloResponse'></output>
</operation>
</portType>
<binding name='HelloWorldBinding' type='tns:HelloWorld'>
<soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='sayGoodbye'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal'/>
</input>
<output>
<soap:body use='literal'/>
</output>
</operation>
<operation name='sayHello'>
<soap:operation soapAction=''/>
<input>
<soap:body use='literal'/>
</input>
<output>
<soap:body use='literal'/>
</output>
</operation>
</binding>
<service name='HelloWorldService'>
<port binding='tns:HelloWorldBinding' name='HelloWorldPort'>
<soap:address location='http://localhost:8080/SampleWS/HelloWorld'/>
</port>
</service>
</definitions>


Thank you
13 years ago
Hi Naren,

This is the exception i am getting on the client side

org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified.
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.checkQName(Unknown Source)
at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.setName(Unknown Source)
at com.sun.org.apache.xerces.internal.dom.ElementNSImpl.<init>(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.<init>(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementFactory.createElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl.createElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.createElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addChildElement(Unknown Source)
at com.sun.xml.internal.messaging.saaj.soap.impl.ElementImpl.addChildElement(Unknown Source)
at com.hex.test.DynamicUPMCall.main(DynamicUPMCall.java:180)
This is the response ---> env:ClientEndpoint {http://webservices.samples.jboss.org/}HelloWorldPort does not contain operation meta data for: {http://webservices.samples.jboss.org/}sayGoddbye



Exception on the server side

14:12:40,054 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
org.jboss.ws.core.CommonSOAPFaultException: Endpoint {http://webservices.samples.jboss.org/}HelloWorldPort does not contain operation meta data for: {http://webservices.samples.jboss.org/}sayGoddbye
at org.jboss.ws.core.server.ServiceEndpointInvoker.getDispatchDestination(ServiceEndpointInvoker.java:474)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:177)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:468)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:293)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:203)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:129)
at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
14:12:40,148 ERROR [SOAPFaultHelperJAXRPC] SOAP request exception
javax.xml.rpc.soap.SOAPFaultException: Endpoint {http://webservices.samples.jboss.org/}HelloWorldPort does not contain operation meta data for: {http://webservices.samples.jboss.org/}sayGoddbye
at org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC.exceptionToFaultMessage(SOAPFaultHelperJAXRPC.java:189)
at org.jboss.ws.core.jaxws.SOAPFaultHelperJAXWS.exceptionToFaultMessage(SOAPFaultHelperJAXWS.java:183)
at org.jboss.ws.core.jaxws.binding.SOAP11BindingJAXWS.createFaultMessageFromException(SOAP11BindingJAXWS.java:102)
at org.jboss.ws.core.CommonSOAPBinding.bindFaultMessage(CommonSOAPBinding.java:650)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:283)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:468)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:293)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:203)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:129)
at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)


Thank you
13 years ago
Hi Naren,

- Yes i am using weblogic.jar and webservices.jar in that standalone java class's classpath to make it work.
- WSDL file , i have attached
- I did the encoding of the byte array to base64Binary String in this way, but it is not working?? please check


// Encoding to base64Binary



// inside main()




//////////////////////////// WSDL File /////////////////////////////////////




Thank you

13 years ago
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
13 years ago