HTTP 传输错误:java.net.MalformedURLException:无协议:REPLACE_WITH_ACTUAL_URL

发布于 2024-11-26 11:14:47 字数 1162 浏览 3 评论 0原文

我正在使用基于存根的客户端方法进行 JAX RPC 这是我的

package com;

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import com.client.BookCatalog;
import com.client.BookCatalogService;
import com.client.BookCatalogService_Impl;

public class Client {

    public static void main(String args[]) throws RemoteException {

        BookCatalogService_Impl service = new BookCatalogService_Impl();

        BookCatalog bc = service.getBookCatalogPort();
        System.out.println(bc.getBookPrice("Web Services"));

    }

}

线程“main”java.rmi.RemoteException 中的客户端异常:HTTP 传输错误:java.net.MalformedURLException:无协议:REPLACE_WITH_ACTUAL_URL;嵌套异常是: HTTP 传输错误:java.net.MalformedURLException:无协议:REPLACE_WITH_ACTUAL_URL 在 com.client.BookCatalog_Stub.getBookPrice(BookCatalog_Stub.java:87) 在 com.Client.main(Client.java:19) 原因:HTTP 传输错误:java.net.MalformedURLException:无协议:REPLACE_WITH_ACTUAL_URL 在 com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTransport.java:148) 在 com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:96) 在 com.client.BookCatalog_Stub.getBookPrice(BookCatalog_Stub.java:70) ... 1 更多

I am using a Stub Based client Approach for JAX RPC
This is my Client

package com;

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import com.client.BookCatalog;
import com.client.BookCatalogService;
import com.client.BookCatalogService_Impl;

public class Client {

    public static void main(String args[]) throws RemoteException {

        BookCatalogService_Impl service = new BookCatalogService_Impl();

        BookCatalog bc = service.getBookCatalogPort();
        System.out.println(bc.getBookPrice("Web Services"));

    }

}

Exception in thread "main" java.rmi.RemoteException: HTTP transport error: java.net.MalformedURLException: no protocol: REPLACE_WITH_ACTUAL_URL; nested exception is:
HTTP transport error: java.net.MalformedURLException: no protocol: REPLACE_WITH_ACTUAL_URL
at com.client.BookCatalog_Stub.getBookPrice(BookCatalog_Stub.java:87)
at com.Client.main(Client.java:19)
Caused by: HTTP transport error: java.net.MalformedURLException: no protocol: REPLACE_WITH_ACTUAL_URL
at com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTransport.java:148)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:96)
at com.client.BookCatalog_Stub.getBookPrice(BookCatalog_Stub.java:70)
... 1 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初懵 2024-12-03 11:14:47

尝试使用更具体版本的 Web 服务客户端类构造函数,例如:

java.net.URL wsdlLocation = new URL("http://service.com/services/Service?wsdl");
javax.xml.namespace.QName qualifiedServiceName = 
    new QName("http://you.service.namespace", "ServiceName");
BookCatalogService_Impl service = 
    new BookCatalogService_Impl(wsdlLocation, qualifiedServiceName);
...

我使用的构造函数仅采用 WSDL 位置,但遇到了相同的错误。添加第二个参数解决了我的问题。

希望这有帮助!

Try using a more specific version of your web service client class constructor, for example:

java.net.URL wsdlLocation = new URL("http://service.com/services/Service?wsdl");
javax.xml.namespace.QName qualifiedServiceName = 
    new QName("http://you.service.namespace", "ServiceName");
BookCatalogService_Impl service = 
    new BookCatalogService_Impl(wsdlLocation, qualifiedServiceName);
...

I was using a constructor that takes only the WSDL location and was getting the same error. Adding the second parameter solved my problem.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文