【问题标题】:Webservice having "No such operation: HTTP GET PATH_INFO"具有“无此类操作:HTTP GET PATH_INFO”的 Web 服务
【发布时间】:2013-01-21 19:06:21
【问题描述】:

我目前有一个 SOAP Web 服务,我正在尝试访问它的端点,但我不断收到此错误:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <soap:Fault>
      <faultcode>soap:Server</faultcode>
        <faultstring>
 No such operation: (HTTP GET PATH_INFO: /camel-example-reportincident/webservices/incident)
        </faultstring>
       </soap:Fault>
    </soap:Body>
 </soap:Envelope>

单元测试

package org.apache.camel.example.reportincident;

import junit.framework.TestCase;

import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.jvnet.mock_javamail.Mailbox;

/**
 * Unit test of our routes
 */
public class ReportIncidentRoutesTest extends TestCase {

private CamelContext camel;

// should be the same address as we have in our route
private static String ADDRESS = "cxf://http://localhost:8080/camel-example-reportincident/webservices/incident"
            + "?serviceClass=org.apache.camel.example.reportincident.ReportIncidentEndpoint"
            + "&wsdlURL=report_incident.wsdl";

protected void startCamel() throws Exception {
    camel = new DefaultCamelContext();
    camel.addRoutes(new ReportIncidentRoutes());
    camel.start();
}

protected static ReportIncidentEndpoint createCXFClient() {
    // we use CXF to create a client for us as its easier than JAXWS and works
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(ReportIncidentEndpoint.class);
    factory.setAddress(ADDRESS);
    return (ReportIncidentEndpoint) factory.create();
}

public void testRendportIncident() throws Exception {
    // start camel
    startCamel();

    // assert mailbox is empty before starting
    Mailbox inbox = Mailbox.get("incident@mycompany.com");
    assertEquals("Should not have mails", 0, inbox.size());

    // create input parameter
    InputReportIncident input = new InputReportIncident();
    input.setIncidentId("123");
    input.setIncidentDate("2008-08-18");
    input.setGivenName("Claus");
    input.setFamilyName("Ibsen");
    input.setSummary("Bla");
    input.setDetails("Bla bla");
    input.setEmail("davsclaus@apache.org");
    input.setPhone("0045 2962 7576");

    // create the webservice client and send the request
    ReportIncidentEndpoint client = createCXFClient();
    OutputReportIncident out = client.reportIncident(input);

    // assert we got a OK back
    assertEquals("0", out.getCode());

    // let some time pass to allow Camel to pickup the file and send it as an email
    Thread.sleep(3000);
    // assert mail box
    assertEquals("Should have got 1 mail", 1, inbox.size());

    // stop camel
    camel.stop();
}

}

我正在尝试将 CFX 端点与我的骆驼路由一起使用,当我将端点地址放入路由中然后对其进行单元测试时,我得到一个“找不到端点://path/to/endpoint ”。

我假设我在尝试访问端点 url 时遇到错误是问题所在,但我什至不知道从哪里开始弄清楚如何解决它。

当我在 SOAP UI 上点击我的网络服务时,它也运行良好。任何帮助将不胜感激,我可以提供任何需要的信息。

【问题讨论】:

    标签: web-services apache-camel endpoint


    【解决方案1】:

    通常,SOAP 服务使用 POST 操作通过 HTTP 公开。您似乎正在尝试使用 GET 操作访问服务。

    我不确定您如何尝试在单元测试中调用该服务,但您需要确保它是 HTTP/POST 调用。如果您使用的是纯 HTTP,那么您可以在调用 HTTP 组件之前设置一个标头。

     .setHeader(Exchange.HTTP_METHOD, constant("POST"))
    

    显示您的单元测试以获得更详细的输入。

    【讨论】:

    • 好的,我编辑了原文,在单元测试中添加了。感谢您的帮助!
    • 我遇到了同样的问题,并注意到如果我们不将“?wsdl”附加到 url 的末尾,我就会遇到肥皂错误。所以基本上像这样的 url 工作 localhost:9081/TST/TSTWebServiceImpl?wsdl 但是下面的 url 会抛出肥皂错误异常,因为 ?wsdl 在 url 的末尾丢失。 localhost:9081/TST/TSTWebServiceImpl 这是一个 JAX-WS 网络服务。
    • @Reddymails ?wsdl 用于从 Web 服务中检索 WSDL 定义。不要与实际服务混淆。
    • 我也有同样的问题。当我不附加“?wsdl”时,我有肥皂法。我怎样才能避免这个异常?
    • 遇到了同样的问题,从 google 发现了这个问题,发现我的 http 客户端正在执行重定向,该重定向导致客户端在新位置使用 GET 请求。必须说服客户端继续使用 POST 请求,现在它工作正常。
    【解决方案2】:

    @grep 我认为这篇文章有点旧,但如果其他有类似问题的人能够回答,我仍然会尝试回答。好吧,我有同样的问题,想知道这些背后的原因是什么。这是我尝试并解决问题的两个步骤。确保您能够在浏览器中访问 wsdl。

    1. 关闭SOAPUI,删除C:/users下用户文件夹下创建的soapui_workspace.xml。
    2. 重新启动 Soap_ui 并打开首选项>代理设置。
    3. 从自动更改为无。
    4. 创建新项目。 这确实解决了我的问题并从 SOAPUI 中的 web 服务获得了响应。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多