cxf解决多网卡的ip获取不正确的问题

        今天帮助网友解决一个问题,cxf对外发布webservice的时候,由于服务器是多网卡环境,从wsdl返回的ip是一个内外地址,解析出错,所以后来在网上查了下,需要设置publishedEndpointUrl设置域名即可。

 

       用ip的时候wsdl如下:

     

<wsdl:definitions xmlns:ns1="http://ws.api.wenbo.taagoo.com/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.ws.api.wenbo.taagoo.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="VirtualMuseumApiWebServiceImplService" targetNamespace="http://impl.ws.api.wenbo.taagoo.com/">
<wsdl:import location="http://172.16.0.5/wenbo-api/ws/virtualMuseumService?wsdl=VirtualMuseumApiWebService.wsdl" namespace="http://ws.api.wenbo.taagoo.com/"></wsdl:import>
<wsdl:binding name="VirtualMuseumApiWebServiceImplServiceSoapBinding" type="ns1:VirtualMuseumApiWebService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getCompanyDetail">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getCompanyDetail">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getCompanyDetailResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getMuseumList">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getMuseumList">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getMuseumListResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getComanyList">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getComanyList">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getComanyListResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="VirtualMuseumApiWebServiceImplService">
<wsdl:port binding="tns:VirtualMuseumApiWebServiceImplServiceSoapBinding" name="VirtualMuseumApiWebServiceImplPort">
<soap:address location="http://172.16.0.5/wenbo-api/ws/virtualMuseumService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

   

   如果在spring里面设置如下配置,即可:

   

<jaxws:endpoint id="VirtualMuseumApiWebServiceImplEndpoint" implementor="#virtualMuseumApiWebServiceImpl"
		address="/virtualMuseumService" >
		<jaxws:properties>    
	      <entry key="publishedEndpointUrl" value="http://www.xxxx.com/wenbo-api/ws/virtualMuseumService" />
	    </jaxws:properties>
		<jaxws:inInterceptors>
			<!-- <ref bean="virtualMuseumHeaderInterceptor" /> -->
			<ref bean="logIn"/>
		</jaxws:inInterceptors>
		<jaxws:outInterceptors>
			<ref bean="logOut"/>
		</jaxws:outInterceptors>
	</jaxws:endpoint>

      最终返回的的wsdl是好的,如下:

   

wsdl:definitions xmlns:ns1="http://ws.api.wenbo.taagoo.com/" xmlns:ns2="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.ws.api.wenbo.taagoo.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="VirtualMuseumApiWebServiceImplService" targetNamespace="http://impl.ws.api.wenbo.taagoo.com/">
<wsdl:import location="http://www.xxx.com/wenbo-api/ws/virtualMuseumService?wsdl=VirtualMuseumApiWebService.wsdl" namespace="http://ws.api.wenbo.taagoo.com/"></wsdl:import>
<wsdl:binding name="VirtualMuseumApiWebServiceImplServiceSoapBinding" type="ns1:VirtualMuseumApiWebService">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getCompanyDetail">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getCompanyDetail">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getCompanyDetailResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getMuseumList">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getMuseumList">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getMuseumListResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getComanyList">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getComanyList">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getComanyListResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="VirtualMuseumApiWebServiceImplService">
<wsdl:port binding="tns:VirtualMuseumApiWebServiceImplServiceSoapBinding" name="VirtualMuseumApiWebServiceImplPort">
<soap:address location="http://www.xxx.com/wenbo-api/ws/virtualMuseumService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

 

 

你可能感兴趣的:(webservice,CXF,多网卡)