axis2使用(2)

用WSDL2Java.bat生成的HelloStub.java有问题.
估计这个工具还不是很完善.
 
准备尝试用官方( http://ws.apache.org/axis2/1_0/userguide3.html)介绍的第1种办法来解决了.
 
以下是HelloClient.java的代码,测试通过,返回信息:
<ns:getcontentresponse xmlns:ns="&amp;lt;a href=" rox.com=""><return></return>Hello">http://rox.com/xsd"><return></return>Hello today,the first day after holiday</ns:getcontentresponse>
 
 
package com.rox;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
public class HelloClient {
    private static EndpointReference targetEPR = new EndpointReference(" http://localhost:8090/axis/services/Hello?wsdl");
    public static void main(String[] args) {
        try {
            OMElement payload = getContentOMElement();
            Options options = new Options();
            options.setTo(targetEPR);
            //Blocking invocation
            ServiceClient sender = new ServiceClient();
            sender.setOptions(options);
            OMElement result = sender.sendReceive(payload);
            System.out.println(result);
        } catch (AxisFault axisFault) {
            axisFault.printStackTrace();
        }
    }
    public static OMElement getContentOMElement() {
        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMNamespace omNs = fac.createOMNamespace(
                " http://rox.com/xsd", "example1");
        OMElement method = fac.createOMElement("getContent", omNs);
        return method;
    }
}

你可能感兴趣的:(apache,html)