Webservice having “No such operation: HTTP GET PAT

2019-07-15 14:05发布

问题:

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>

UNIT TEST

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();
}

}

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

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.

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.

回答1:

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

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.



回答2:

@grep I see this post as bit old, but still will try to answer if anyone else with similar problem is able to. Well, I had the same isssue and wondered what were the reason s behind those. here are the two steps that i tried and fixed up the issue. make sure you are able to access the wsdl in browser.

  1. Close the SOAPUI, delete the soapui_workspace.xml created in user folder under C:/users.
  2. Restart the Soap_ui and open up preferences>Proxy setting.
  3. Change from automatic to None.
  4. Create new project. This did solved my issue and got the response from webservice in SOAPUI.