具有“没有这样的操作:HTTP GET PATH_INFO"的 Web 服务 [英] Webservice having "No such operation: HTTP GET PATH_INFO"

查看:15
本文介绍了具有“没有这样的操作:HTTP GET PATH_INFO"的 Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I currently have a SOAP web service and I am trying to access it's endpoint but I keep getting this error:

<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".

I am attempting to use CFX endpoint along with my camel routing and when I am putting the endpoint address in the route and then unit testing it I am getting a "No endpoint could be found for: //path/to/endpoint".

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

I am assuming that the fact that I am getting an error when I try to access the endpoint url is the issue but I do not even know where to begin on figuring out how to fix it.

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

When I hit my webservice on SOAP UI it runs fine as well. Any help would be greatly appreciated, and I can provide any info that is needed.

推荐答案

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

Typically, SOAP services are exposed over HTTP using the POST operation. You seem to be trying to access the service using the GET operation.

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

I am not sure how you try to invoke the service in your unit test, but you need to make sure it's a HTTP/POST call. If you are using plain HTTP, then you could set a header before invoking the HTTP component.

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

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

Show your unit test for more detailed input.

这篇关于具有“没有这样的操作:HTTP GET PATH_INFO"的 Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆