我正在尝试通过Postman chrome扩展程序发送SOAP请求.我的请求正文在Postman中看起来像这样:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://partnerapi.somewhere.com/">
<soapenv:Body>
<ns1:GetCustomers>
<GetCustomersRequest>
<APIKey>SECRET</APIKey>
<PartnerKey></PartnerKey>
<SearchText></SearchText>
<ItemsPerPage>50</ItemsPerPage>
<PageNumber>1</PageNumber>
<Fields></Fields>
<OrderBy></OrderBy>
</GetCustomersRequest>
</ns1:GetCustomers>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
编辑:
单击Generate CodePostman中的按钮提供以下代码段:
POST /PartnerAPI.asmx HTTP/1.1
Host: localhost:3000
Content-Type: text/xml
SOAPAction: http://partnerapi.somewhere.com/GetCustomers
Cache-Control: no-cache
Postman-Token: 1af78251-9d36-0c94-d0e3-21f7e37ffc41
Run Code Online (Sandbox Code Playgroud)
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://partnerapi.somewhere.com/">
<soapenv:Body>
<ns1:GetCustomers>
<GetCustomersRequest>
<APIKey>SECRET</APIKey>
<PartnerKey></PartnerKey>
<SearchText></SearchText>
<ItemsPerPage>50</ItemsPerPage>
<PageNumber>1</PageNumber>
<Fields></Fields>
<OrderBy></OrderBy>
</GetCustomersRequest>
</ns1:GetCustomers>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
我有在Visual Studio中运行的Web服务,并且我在web方法中设置了一个断点,该断点正被命中,因此请求到达端点.
Web方法签名如下所示:
[WebMethod]
public CustomersObject GetCustomers(RequestObjects.GetCustomersRequest GetCustomersRequest)
Run Code Online (Sandbox Code Playgroud)
但GetCustomersRequest参数始终为NULL.
这个GetCustomersRequest类看起来像这样:
public class GetCustomersRequest {
public string APIKey;
public string PartnerKey;
public string …Run Code Online (Sandbox Code Playgroud) 我是Mockito和Spring的RestTemplate的新手。我正在为某个功能进行JUnit测试,该功能可以将请求发送到Web服务并通过使用RestTemplate获得响应。我希望服务器以我想要的响应进行响应,以便我可以基于此响应测试功能。我正在使用Mockito进行嘲笑。
我不确定我要去哪里错。我不是在制作适当的模拟游戏吗?我的JSON对象映射器是否配置不正确?
定义RestTemplate bean的配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
<bean class="org.springframework.http.converter.xml.SourceHttpMessageConverter"/>
<bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<property name="marshaller" ref="xsStreamMarshaller" />
<property name="unmarshaller" ref="xsStreamMarshaller" />
</bean>
</list>
</property>
</bean>
<bean id="xsStreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller"></bean>
</beans>
Run Code Online (Sandbox Code Playgroud)
我的DTO:
import org.codehaus.jackson.annotate.JsonWriteNullProperties;
@JsonWriteNullProperties(false)
public abstract class BaseDTO {
protected boolean error;
public boolean isError() {
return error;
}
public void setError(boolean error) {
this.error = error;
}
}
public class ChildDTO extends CommercialBaseDTO { …Run Code Online (Sandbox Code Playgroud)