我试图用以下方式用 mockito 存根,但由于代理它不起作用,但在删除代理后它正在工作
mockito 存根(以下代码在没有代理的情况下工作):
stubFor(post ("/abcbox-uat/abc-wsdl")
.willReturn(aResponse()
.proxiedFrom("http://zscaler.abc.com:10068")
.withStatus ( 200 )
.withHeader("Content-Type", "text/xml; charset=utf-8")
.withBodyFile("xml/" + "fqe-res.xml")
)
);
要存根的代码:
@Bean public WebServiceTemplate webServiceTemplateFlx() 抛出 SOAPException {
//Setup proxy
final HttpClientBuilder builder;
builder = HttpClientBuilder.create();
builder.addInterceptorFirst(new HttpComponentsMessageSender.RemoveSoapHeadersInterceptor());
final HttpHost proxy = new HttpHost("zscaler.abc.com", 10068);
builder.setProxy(proxy);
final CloseableHttpClient httpClient = builder.build();
final HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender(httpClient);
final WebServiceTemplate webServiceTemplate = new WebServiceTemplate(this.saajSoapMessageFactoryFlx());
webServiceTemplate.setDefaultUri(String.format("%s://%s", this.fareLogixRetrievalClientConfigHolder.getProtocol(),
this.fareLogixRetrievalClientConfigHolder.getServiceEndpoint()));
webServiceTemplate.setMessageSender(messageSender);
webServiceTemplate.setMarshaller(this.jaxb2MarshallerFlx());
webServiceTemplate.setUnmarshaller(this.jaxb2UnMarshallerFlx());
return webServiceTemplate;
}
删除代理后能够存根此代码。
我收到 500 错误。