• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web Service Failed to call binding provider

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written web service example program using jboss as 7.0.2 Final profile. I want to add MAINTAIN_SESSION_PROPERTY to the client, but while casting to BindingProvider it generate the following exception
org.apache.cxf.calculator.CalculatorServiceSoapBindingStub cannot be cast to javax.xml.ws.BindingProvider

My Web Service Code is

import javax.jws.WebService;

import org.apache.cxf.calculator.CalculatorPortType;
import org.apache.cxf.calculator.types.CalculatorFault;

@WebService(serviceName = "CalculatorService",
portName = "CalculatorPort",
targetNamespace = "http://apache.org/cxf/calculator",
endpointInterface = "org.apache.cxf.calculator.CalculatorPortType"
)
public class CalculatorImpl implements CalculatorPortType {
public int add(int number1, int number2) throws AddNumbersFault {
if (number1 < 0 || number2 < 0) {
CalculatorFault fault = new CalculatorFault();
fault.setMessage("Negative number cant be added!");
fault.setFaultInfo("Numbers: " + number1 + ", " + number2);
throw new AddNumbersFault("Negative number cant be added!", fault);
}
return number1 + number2;
}

}


and client code is

public class CalculatorWSClient {
private static final QName SERVICE_1 =
new QName("http://apache.org/cxf/calculator", "CalculatorService");

private static final QName PORT_1 =
new QName("http://apache.org/cxf/calculator", "CalculatorPort");


public static void main(String[] args) throws MalformedURLException, CalculatorFault, RemoteException, ServiceException {

String endpointAddress =
"http://localhost:8080/CalculatorWS?wsdl";


CalculatorService calcService=new CalculatorServiceLocator(endpointAddress, SERVICE_1);
CalculatorPortType port=calcService.getCalculatorPort();
System.out.println("\n\n\t-----1 Port: "+port);
BindingProvider bindingProvider=(BindingProvider)port;
Map<String,Object> rc = (Map<String,Object>)bindingProvider.getRequestContext();
System.out.println("\n\n\t-----1 Result: "+port.add(10, 20));

}


The generated WebServiceClient are :
CalculatorFault.java
CalculatorPortType.java
CalculatorPortTypeProxy.java
CalculatorService.java
CalculatorServiceLocator.java
CalculatorServiceSoapBindingStub.java


Kindly help me.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you modify it like this and try

 
Nilesh Mishra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have changed my code as below

CalculatorService calcService=new CalculatorServiceLocator(endpointAddress, SERVICE_1);
CalculatorPortType port=calcService.getCalculatorPort();
System.out.println("\n\n\t-----1 Port: "+port);

Map<String,Object> rc = (Map<String,Object>) (((BindingProvider)port).getRequestContext());
System.out.println("\n\n\t-----1 Result: "+port.add(10, 20));

But exception occur as:

-----1 Port: org.apache.cxf.calculator.CalculatorServiceSoapBindingStub@110c424
Exception in thread "main" java.lang.ClassCastException: org.apache.cxf.calculator.CalculatorServiceSoapBindingStub cannot be cast to javax.xml.ws.BindingProvider
at CalculatorWSClient.main(CalculatorWSClient.java:54)
 
Divya Janyavula
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you should check if your Apache CXF version supports JAX-WS. Somewhere the JAX-RPC and JAX-WS are getting mixed.
 
Nilesh Mishra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Jboss AS 7.0.2-Final version with eclipse juno for generating web service and it client
 
Ranch Hand
Posts: 30
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nilesh, did you get any solution of this problem?? I am stuck in the same issue.. Please help..
 
Nilesh Mishra
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sandy Ghosh wrote:Hi Nilesh, did you get any solution of this problem?? I am stuck in the same issue.. Please help..



Note: Kindly don't use eclipse based Web Service client tools.


1. download the apache cxf from http://cxf.apache.org/download.html
2. Set path variable for apache cxf.
3. open command prompt and go to your the wsdl file location.
4. run the following command to generate the client code for web service.

wsdl2java -frontend jaxws21 CalculatorWS.wsdl

above command generate the java client code for apache cxf based web service.

Use the generated client code in your project for writing web service client.

Below i have metioned how instantiate port and set the session property

public CalculatorWS port;

Service service = Service.create(new URL(""http://localhost:8080/CalculatorWS?wsdl"), new QName("http://apache.org/cxf/calculator", "CalculatorService");
port = service.getPort(new QName("http://apache.org/cxf/calculator", "CalculatorPort");, CalculatorWS.class);

((BindingProvider)Helper.port).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
((BindingProvider)port).getRequestContext().put("javax.xml.ws.client.connectionTimeout","18000000"); //60*1000*60*5 =5 hours
((BindingProvider) port).getRequestContext().put("javax.xml.ws.client.receiveTimeout", "3600000"); //30*1000*60 - 30 minute - Duration Defines Web Service Response Time





 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to handle below error: javax.xml.ws.WebServiceException: com.sun.xml.wss.impl.XWSSecurityRuntimeException: WSS1601: Security Requirements not met - Transport binding configured in policy but incoming message was not SSL enabled
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic