1

I'm tring to made a dinamic WS call using jax-ws.

But I can't create the dispatcher, the code is:

String namespace= "http://wsf.cdyne.com/WeatherWS/Weather.asmx";
try {
    QName serviceName = new QName(namespace, "GetCityForecastByZIP");
    Service s = Service.create(serviceName);
    QName portName = new QName(namespace, "WeatherSoap12");
    Dispatch<DOMSource> dispatch = s.createDispatch(portName,
                                                  DOMSource.class,
                                                  Service.Mode.PAYLOAD);
...

The error is javax.xml.ws.WebServiceException: {http://wsf.cdyne.com/WeatherWS/Weather.asmx}WeatherSoap12 is not a valid port. Valid ports are:

I have ckect the WSDL at http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL and I can't identify the reason of the error.

Any help?

4

1 回答 1

2

SOLVED. The sample code used was incomplete, I need to add the port to the server

s.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING, WSDL_ENDPOINT_URL);
于 2012-12-04T08:37:56.863 回答