我有以下類,我如何獲取傳入請求源的IP地址?我已經檢查了幾個解決方案,在互聯網上也沒有找到一些合適的一個,如果您需要了解項目結構,我可以添加更多的信息,感謝如何獲取傳入請求的IP地址SOAP
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "doSomething")
public DefaultWsdl11Definition defaultValidateWsdl11Definition(XsdSchema validateSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("ValidatePort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://www.org.com/validate");
wsdl11Definition.setSchema(validateSchema);
return wsdl11Definition;
}
@Bean(name = "doSecond")
public DefaultWsdl11Definition defaultActionWsdl11Definition(XsdSchema actionSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("ActionPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://www.org.com/action");
wsdl11Definition.setSchema(actionSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema validateSchema() {
return new SimpleXsdSchema(new ClassPathResource("doSomething.xsd"));
}
@Bean
public XsdSchema actionSchema() {
return new SimpleXsdSchema(new ClassPathResource("doSecond.xsd"));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.org.com/doSomething"
targetNamespace="http://www.org.com/doSomething" elementFormDefault="qualified">
<xs:element name="getActionRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="Username" type="xs:string"/>
<xs:element name="Password" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getDoSomethingResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="Code" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
你檢查過HTTP頭文件嗎?看到[這](http://stackoverflow.com/questions/559155/how-do-i-get-a-httpservletrequest-in-my-spring-beans) – Tibrogargan
謝謝,讓我檢查它 – imoteb