gpt4 book ai didi

web-services - 具有 "No such operation: HTTP GET PATH_INFO"的网络服务

转载 作者:行者123 更新时间:2023-12-04 03:56:31 24 4
gpt4 key购买 nike

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

<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 端点与我的 Camel 路由一起使用,当我将端点地址放入路由中然后对其进行单元测试时,我收到“找不到端点://path/to/endpoint ".

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

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

最佳答案

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

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

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

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

关于web-services - 具有 "No such operation: HTTP GET PATH_INFO"的网络服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14445484/

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