java SOAP - 不知道我的端点 URL 是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12481129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SOAP - don't know what my endpoint URL is
提问by Phil
I hope this problem is extremely simple and it's just me being an idiot. I am new to SOAP and am attempting to set up a SOAP WebService (using Java and Spring) and then using the tool SoapUI I attempt to send a SOAP request to my Web service. However I always get 404 Not Found errors when I submit my request. I suspect / hope that I have just set my Endpoint incorrectly in SoapUI, but I don't know what value I should be putting there. Can anyone help?
我希望这个问题非常简单,只是我是个白痴。我是 SOAP 新手,正在尝试设置 SOAP WebService(使用 Java 和 Spring),然后使用工具 SoapUI 我尝试向我的 Web 服务发送 SOAP 请求。但是,当我提交请求时,我总是收到 404 Not Found 错误。我怀疑/希望我刚刚在 SoapUI 中错误地设置了我的端点,但我不知道我应该把什么值放在那里。任何人都可以帮忙吗?
These are the steps I have taken to setup my WebApp with SOAP support:
这些是我为设置具有 SOAP 支持的 WebApp 所采取的步骤:
1) I am using an existing WebApp (which has existing REST Web Services) running in Spring Tool Suite (which is based on Eclipse) and using Jetty. In my web.xml file I added a new SOAP Web Service:
1) 我正在使用在 Spring Tool Suite(基于 Eclipse)中运行并使用 Jetty 的现有 WebApp(它具有现有的 REST Web 服务)。在我的 web.xml 文件中,我添加了一个新的 SOAP Web 服务:
<servlet-mapping>
<servlet-name>SOAPWebService</servlet-name>
<url-pattern>/ws/SOAP/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>SOAPWebService</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
2) I created a new class "ProjectSearchEndpoint" which has an annotation of @Endpoint. The payload root = @PayloadRoot(namespace = "http://FOO.FOO/foo", localPart = "ProjectRequest")
2)我创建了一个新类“ProjectSearchEndpoint”,它有一个@Endpoint的注释。有效载荷根 = @PayloadRoot(namespace = "http://FOO.FOO/foo", localPart = "ProjectRequest")
3) I added the DSD to the WEB-INF of my WebApp: ws-project.xsd
3)我将 DSD 添加到我的 WebApp 的 WEB-INF 中:ws-project.xsd
4) I created a servlet XML file called: SOAPWebService-servlet.xml which references the DSD
4)我创建了一个名为:SOAPWebService-servlet.xml 的 servlet XML 文件,它引用了 DSD
<bean id="projectSearch" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
<property name="schema" ref="schema"/>
<property name="portTypeName" value="ProjectSearch"/>
</bean>
<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
<property name="xsd" value="/WEB-INF/ws-project.xsd"/>
</bean>
NOTE:the endpoint code and DSD come from the blog: http://javaclue.blogspot.co.uk/2012/05/soap-web-service-using-spring-ws-20.htmlI edited the namespace to make it "http://FOO.FOO/foo" but apart from that the code is the same although I have added System.out lines to show when the object is constructed (it is) and when the "searchProjects" method is invoked (it never is).
注意:端点代码和 DSD 来自博客:http: //javaclue.blogspot.co.uk/2012/05/soap-web-service-using-spring-ws-20.html我编辑了命名空间以使其成为“http://FOO.FOO/foo”但除此之外代码是相同的,尽管我添加了 System.out 行来显示对象何时构造(它是)以及何时调用“searchProjects”方法(它从来没有)。
I can start my webApp successfully and if in my browser I navigate to the URL:
我可以成功启动我的 webApp,如果我在浏览器中导航到 URL:
http://localhost:8080/MyApp/ws/SOAP/projectSearch.wsdl
I get to see the WSDL. All good so far.
我可以看到 WSDL。到目前为止一切都很好。
When I use SoapUI I create a new project and pass in the WSDL. SoapUI seems happy. I ask for a request and SoapUI creates a Soap Envelope with my ProjectRequest in it. Everything is going very well! However to submit this request SoapUI wants an Endpoint. I think my endpoint is:
当我使用 SoapUI 时,我创建了一个新项目并传入了 WSDL。SoapUI 看起来很开心。我请求一个请求,SoapUI 创建一个包含我的 ProjectRequest 的 Soap Envelope。一切都很顺利!然而,提交这个请求 SoapUI 需要一个端点。我认为我的终点是:
http://localhost:8080/MyApp/ws/SOAP/
but this just returns a 404 not found. Trying other combinations such as
但这只会返回未找到的 404。尝试其他组合,例如
http://localhost:8080/MyApp/ws/SOAP/projectSearch
http://localhost:8080/MyApp/ws/SOAP/projectSearch?wsdl
http://localhost:8080/MyApp/ws/SOAP/ProjectRequest
all result in 404. What is my endpoint? What value should I be putting into SoapUI?
所有结果都是 404。我的端点是什么?我应该在 SoapUI 中投入什么价值?
Update 1
更新 1
For clarity this is what I am doing in soapUI
为了清楚起见,这就是我在soapUI中所做的
Having started soapUI, I create a "new soapUI Project". The name is A1. The Initial WSDL is:
启动soapUI 后,我创建了一个“新的soapUI 项目”。名字是A1。初始 WSDL 是:
http://localhost:8080/MyApp/ws/SOAP/projectSearch.wsdl
also "Create Requests" is ticked in the dialog box.
在对话框中也勾选了“创建请求”。
I click OK and it creates a ProjectSearchSoap11 (with an icon of a green I next to it) with a single Project underneath it (icon of red arrows) and under that "Request1" (icon the word SOAP). I right-click Request1 and select "Show Request Editor". This displays a window with a SOAP envelope and my namespace and ProjectRequest. This all looks good.
我单击“确定”,它会创建一个 ProjectSearchSoap11(旁边有一个绿色的 I 图标),它下面有一个项目(红色箭头图标),在“Request1”下面(图标 SOAP 一词)。我右键单击 Request1 并选择“显示请求编辑器”。这将显示一个带有 SOAP 信封以及我的命名空间和 ProjectRequest 的窗口。这一切看起来都不错。
I now want to click "Submit request to sepecified Endpoint URL" (green arrow at top-left) but this is greyed-out until I specify an endpoint (to the right). I click on the endpoints drop-down and select "edit-current". A dialog appears. I enter:
我现在想单击“向指定的端点 URL 提交请求”(左上角的绿色箭头),但在我指定端点(右侧)之前这是灰色的。我点击端点下拉菜单并选择“edit-current”。出现一个对话框。我输入:
http://localhost:8080/MyApp/ws/SOAP/
and click ok. Now the run icon is enabled (green). Clicking this icon then results in a "response" window appearing, which is blank, but the raw data is:
并单击确定。现在运行图标已启用(绿色)。单击此图标会导致出现一个“响应”窗口,该窗口为空白,但原始数据为:
HTTP/1.1 404 Not Found
Content-Length: 0
Server: Jetty(6.1.26)
I am guessing that the endpoint I am choosing is wrong. Can you confirm that this is the wrong format or I'm missing a suffix of some kind. If you think it's correct then it must be my setup on the web application that is at fault.
我猜我选择的端点是错误的。你能确认这是错误的格式还是我缺少某种后缀。如果您认为它是正确的,那么一定是我在 Web 应用程序上的设置有问题。
Thanks,
谢谢,
Phil
菲尔
回答by chrismead
When you create the soapui testrequest it should populate the endpoint field for you.
当您创建 soapui 测试请求时,它应该为您填充端点字段。
You can also run the 'sample requests' under the green 'I' icon, at least to test your endpoint. I don't recommend editing these to use as your actual tests, but I think that many people do use SoapUI that way.
您还可以在绿色“I”图标下运行“示例请求”,至少可以测试您的端点。我不建议编辑这些以用作您的实际测试,但我认为很多人确实以这种方式使用 SoapUI。
What do you mean by 'I ask for a request'? You should be able to right click the test request two levels under the green 'I' and select add to testcase. There are a couple dialogs after that where you can take the defaults. It will create a Junit type structure: a test suite and a test case. Under that are test steps which you can execute by themselves or as part of the suite or testcase.
'我请求一个请求'是什么意思?您应该能够右键单击绿色“I”下的两个级别的测试请求,然后选择添加到测试用例。之后有几个对话框,您可以在其中采用默认值。它将创建一个 Junit 类型结构:一个测试套件和一个测试用例。下面是测试步骤,您可以自己执行,也可以作为套件或测试用例的一部分执行。
EDIT 1:
编辑 1:
To me that doesn't sound normal. Unfortunately, I haven't written anything but simple demo services, though...
对我来说这听起来不正常。不幸的是,我除了简单的演示服务之外什么都没写,不过……