我想为端点创建SoapUI模拟服务:“ / product / 123456 / details /”。这里123456是路径变量。 我创建了一个肥皂ui模拟服务,其路径为“ / product /”,作为回应,我只是给出了该路径(仅供测试)。 当我在端口8210上的SoapUI中运行此模拟服务时,单击“ http://localhost:8210/product/123456/details”非常完美。 我得到以下回应。
"/product/123456/details"
但是当我将其作为mymockwar war部署在端口8080上运行的tomcat中时, 如果我点击“ http://localhost:8080/mymockwar/product/123456/details/”, 然后我得到如下响应。
<html>
<head>
<title>soapUI MockServices Log for project [MyNewMock]</title>
</head>
<body>
<h3>Log is disabled.</h3>
</body>
</html>
现在,如果我按下“ http://localhost:8080/mymockwar/product/”,它将起作用,并且给出的响应为
"/product/"
在tomcat中部署后,如何使它与路径变量一起使用? Tomcat版本:7.0.22 SoapUI版本:4.5.2
下面的模拟服务xml。
<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project xmlns:con="http://eviware.com/soapui/config" activeEnvironment="Default" name="MyNewMock" resourceRoot="" soapui-version="4.5.2" abortOnError="false" runType="SEQUENTIAL">
<con:settings />
<con:mockService port="8210" path="/product/" host="localhost" name="testSoapMock" bindToHostOnly="false" docroot="">
<con:settings>
<con:setting id="com.eviware.soapui.impl.wsdl.mock.WsdlMockService@require-soap-action">false</con:setting>
</con:settings>
<con:properties />
<con:onRequestScript>def method = mockRequest.method;
def path = mockRequest.path;
log.info path
def response = mockRequest.getHttpResponse()
response.setContentType("application/json")
def writer = response.getWriter();
writer.write(path)
writer.close()</con:onRequestScript>
</con:mockService>
<con:properties />
<con:wssContainer />
</con:soapui-project>
答案 0 :(得分:0)
我遇到同样的异常,解决方法是url中的名称和xml中的名称要求它们相同或名称冲突
例如:
URL: http://localhost:8088/mocks/queryBalance
Request :<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns3:queryBalanceRequestMsg xmlns:ns2="http://www.huawei.com/bme/cbsinterface/cbscommon" xmlns:ns3="http://www.huawei.com/bme/cbsinterface/arservices" xmlns:ns4="http://cbs.huawei.com/ar/wsservice/arcommon">
<requestHeader>
<ns2:ownershipInfo>
<ns2:beId>101</ns2:beId>
</ns2:ownershipInfo>
<ns2:accessSecurity>
<ns2:loginSystemCode>ecare01</ns2:loginSystemCode>
<ns2:password>Admin123!</ns2:password>
</ns2:accessSecurity>
<ns2:operatorInfo>
<ns2:operatorId>9001</ns2:operatorId>
</ns2:operatorInfo>
</requestHeader>
<queryBalanceRequest>
<ns3:serviceNumber>1511661998</ns3:serviceNumber>
</queryBalanceRequest>
</ns3:queryBalanceRequestMsg>
</soap:Body>
</soap:Envelope>
URL为queryBalance时,它返回您的异常