【问题标题】:how to use Service,ServiceLocator,portType,porttypeProxy and stub to create a java client如何使用 Service、ServiceLocator、portType、porttypeProxy 和 stub 创建 java 客户端
【发布时间】:2011-10-19 17:21:06
【问题描述】:

我使用了轴 Web 服务客户端向导 + 开发客户端滑块来生成文件:

  • Mage_Api_Model_Server_HandlerBindingStub
  • Mage_Api_Model_Server_HandlerPortType
  • Mage_Api_Model_Server_HandlerPortTypeProxy
  • MagentoService
  • Magento 服务定位器 请看my post

我正在尝试让客户像这样:

package Magento;

  public class MyClient {  
public static void main(String[] args) {  
    try{  
        MagentoServiceLocator msl = new MagentoServiceLocator();  
        MagentoService ms = (MagentoService) msl.WHICH_METHOD_TO_CALL();  

        double product_list = ms.catalogProductList;  
        System.out.println("Product List: " + product_list);  

    } catch (Exception e) {
        e.printStackTrace();
    }
  }

}

我尽我所能提供的任何帮助,但没有得到我应该调用哪种方法来访问 php webservice 方法。 有什么帮助吗?

【问题讨论】:

    标签: java web-services


    【解决方案1】:

    为给定的 wsdl 创建一个客户端,然后试试这个:

    WebServiceSoapBindingStub stub = new WebServiceSoapBindingStub();
    stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, wsdlUrl); 
    WebService service = (WebService) stub;
    service.authenticateUser(username,password); //service.yourservicename
    

    更多对您有帮助的信息。

    http://www.codeproject.com/KB/java/edujini_webservice_java.aspx

    【讨论】: