gpt4 book ai didi

java - 如何通过 netbeans 使用 wsdl 中的 w3schools tempCnvertor Web 服务?

转载 作者:行者123 更新时间:2023-11-30 06:40:22 30 4
gpt4 key购买 nike

我一直在尝试使用来自

的 w3schools tempConvertor Web 服务

https://www.w3schools.com/xml/tempconvert.asmx?WSDL

它在生成客户端类之前给了我这个警告消息

parsing WSDL...

[WARNING] SOAP port "TempConvertSoap12": uses a non-standard SOAP 1.2 binding. line 147 of file:/C:/Users/Bigesta/Documents/NetBeansProjects/JavaebServiceDemo/xml-resources/web-service-references/tempconvert/wsdl/www.w3schools.com/xml/tempconvert.asmx.wsdl

[WARNING] Port "TempConvertHttpPost" is not a SOAP port, it has no soap:address line 150 of file:/C:/Users/Bigesta/Documents/NetBeansProjects/JavaebServiceDemo/xml-resources/web-service-references/tempconvert/wsdl/www.w3schools.com/xml/tempconvert.asmx.wsdl

[WARNING] port "TempConvertHttpPost": not a standard SOAP port. The generated artifacts may not work with JAX-WS runtime. line 150 of file:/C:/Users/Bigesta/Documents/NetBeansProjects/JavaebServiceDemo/xml-resources/web-service-references/tempconvert/wsdl/www.w3schools.com/xml/tempconvert.asmx.wsdl

Generating code...

https\www_w3schools_com\xml\CelsiusToFahrenheit.java https\www_w3schools_com\xml\CelsiusToFahrenheitResponse.java https\www_w3schools_com\xml\FahrenheitToCelsius.java https\www_w3schools_com\xml\FahrenheitToCelsiusResponse.java https\www_w3schools_com\xml\ObjectFactory.java https\www_w3schools_com\xml\TempConvert.java https\www_w3schools_com\xml\TempConvertHttpPost.java https\www_w3schools_com\xml\TempConvertSoap.java https\www_w3schools_com\xml\package-info.java Copying 9 files to C:\Users\Bigesta\Documents\NetBeansProjects\JavaebServiceDemo\build\generated-sources\jax-ws BUILD SUCCESSFUL (total time: 8 seconds)

每当我尝试调用该服务时,我都会遇到此异常

Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 301: Moved Permanently at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCode(HttpTransportPipe.java:310) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.createResponsePacket(HttpTransportPipe.java:259) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:217) at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:130) at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:95) at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:1121) at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:1035) at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:1004) at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:862) at com.sun.xml.internal.ws.client.Stub.process(Stub.java:448) at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:178) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147) at com.sun.proxy.$Proxy31.fahrenheitToCelsius(Unknown Source) at javaebservicedemo.JavaebServiceDemo.fahrenheitToCelsius(JavaebServiceDemo.java:26) at javaebservicedemo.JavaebServiceDemo.main(JavaebServiceDemo.java:19)

我怎样才能让它发挥作用?

最佳答案

当解析 WSDL 时,警告指出 WSDL 不遵循 SOAP 1.2 绑定(bind)约定,特别是:SOAP 端口没有soap:address。此 WSDL 可能试图同时支持 SOAP 1.1 和 1.2

您收到的回复是 301: Moved Permanently它正在尝试重定向您。

这里有一个例子:https://www.w3schools.com/xml/tempconvert.asmx?op=FahrenheitToCelsius

但是,当我使用帖子示例时,我收到 500 服务器错误,这不是一个好兆头。

为了节省时间,我建议在创建演示之前使用 SOAPUI 等工具来测试和验证服务是否正常工作。您可以尝试使用不同的服务,例如 http://www.webservicex.net/ConvertTemperature.asmx?WSDL

关于java - 如何通过 netbeans 使用 wsdl 中的 w3schools tempCnvertor Web 服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44453885/

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