2016-09-07 46 views
0

我想使用ihomefinder的測試API來獲取數據並將其插入到我自己的數據庫中。我使用Spring MVC和他們提供的鏈接,我在我的pom.xml中配置以獲取數據是http://axisws.idxre.com:8080/axis2/services/IHFPartnerServices?wsdl。 從我發現,所有的提供的API在包com.ihomefinder.api各種搜索所以我把它太到pom.xml中從Java調用iHomefinder的IDX MLS SOAP API Spring MVC

下面是pom.xml的代碼:

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-ws</artifactId> 
     <version>1.3.1.RELEASE</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.jvnet.jaxb2.maven2</groupId> 
      <artifactId>maven-jaxb2-plugin</artifactId> 
      <version>0.13.1</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>generate</goal> 
        </goals> 
       </execution> 
      </executions> 
      <configuration> 
       <schemaLanguage>WSDL</schemaLanguage> 
       <generatePackage>com.ihomefinder.api</generatePackage> 
       <schemas> 
        <schema> 
         <url>http://axisws.idxre.com:8080/axis2/services/IHFPartnerServices?wsdl</url> 
        </schema> 
       </schemas> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

現在我試圖登錄與他們提供的測試用戶名和密碼,但要打登錄服務,我需要創建com.ihomefinder.api包中找不到的請求對象類。

這裏是我使用發出請求的Java代碼:

import javax.xml.bind.JAXBElement;  
import org.springframework.ws.client.core.support.WebServiceGatewaySupport; 
import org.springframework.ws.soap.client.core.SoapActionCallback; 
import com.ihomefinder.api.Login; 
import com.ihomefinder.api.ObjectFactory; 

public class IdxMls extends WebServiceGatewaySupport { 

    public void main() { 
     // TODO Auto-generated method stub 
     ObjectFactory objectFactory = new ObjectFactory(); 
     JAXBElement<String> user = objectFactory.createLoginUsername("username"); 
     JAXBElement<String> pass = objectFactory.createLoginPassword("password"); 
     Login login = new Login(); 
     login.setUsername(user); 
     login.setPassword(pass);   
     Integer int1 = (Integer) getWebServiceTemplate().marshalSendAndReceive(login, new SoapActionCallback("http://axisws.idxre.com:8080/axis2/services/Login")); 
     System.out.println(int1); 
    } 

    public static void main(String[] args) { 
     IdxMls idxMls = new IdxMls(); 
     idxMls.main(); 
    } 

} 

我覺得上面的代碼不健全有些東西真的錯過。那麼,任何人都可以幫助我糾正可以從API獲得響應的代碼嗎?

回答