gpt4 book ai didi

javax.xml.ws.WebServiceException : is not a valid port

转载 作者:太空宇宙 更新时间:2023-11-04 07:56:35 27 4
gpt4 key购买 nike

我正在尝试使用 jax-ws 进行动态 WS 调用。

但是我无法创建调度程序,代码是:

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);
...

错误是javax.xml.ws.WebServiceException:{http://wsf.cdyne.com/WeatherWS/Weather.asmx}WeatherSoap12 不是有效端口。有效端口是:

我已在 http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL 处检查了 WSDL我无法确定错误的原因。

有什么帮助吗?

最佳答案

已解决。使用的示例代码不完整,我需要将端口添加到服务器

s.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING, WSDL_ENDPOINT_URL);

关于javax.xml.ws.WebServiceException : is not a valid port,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13530484/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com