wsdl2java⾃动⽣成java代码与使⽤范例步骤1:根据WSDL(url)⽣成java代码。
1.1下载附件的压缩⽂件,并解压之。
1.2 在解压的⽬录下⾯到 WSDL2Java(URL).bat 并⽤记事本⽅式打开以便进⾏编辑。
1.3 在1.2中 替换 %Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o%Output_Path% -p%Package%
后⾯的url为⾃⼰的url.后保存.
1.4 双击 WSDL2Java(URL).bat,即可执⾏⽣成java ⾃动代码。
步骤2:使⽤⽰例:
package st.policy;
i.RemoteException;
import java.util.ArrayList;
import java.util.List;
l.rpc.ServiceException;
import org.apache.axis.AxisFault;
import org.junit.Before;
import org.junit.Test;
import com.sxy.policy._51book.webservice.all.client.GetPolicyReply;
import com.sxy.policy._51book.webservice.all.client.GetPolicyRequest;
import com.sxy.policy._51book.webservice.all.client.GetPolicyServiceImpl_1_0ServiceLocator;
import com.sxy.policy._51book.webservice.all.client.GetPolicyService_1_0;
import com.sxy.policy._51book.webservice.all.client.WsPolicyData;
import com.sxy.service.iservice.policy.IPolicy51BookService;
import com.stant.Tool;
import com.system.SpringContext;
public class Policyi51BookGetAllTest
{
private IPolicy51BookService policy51BookService;
@Before
public void init()
{
policy51BookService = (SpringContext().getBeanInstance(IPolicy51BookService.class); }
@Test
public void testGetPolicy()
{
try
{
GetPolicyServiceImpl_1_0ServiceLocator locator = new GetPolicyServiceImpl_1_0ServiceLocator();
GetPolicyService_1_0 getPolicyService = GetPolicyServiceImpl_1_0Port();
GetPolicyRequest request = new GetPolicyRequest();
String agencyCode = "";
String securtyCode = "";
int needSpePricePolicy = 0;
int needSpePricePolicy = 0;
int needSpeRulePolicy = 0;
int pageNo = 1;
int rowPerPage = 100;
request.setAgencyCode(agencyCode);
request.setNeedSpePricePolicy(needSpePricePolicy);
request.setNeedSpeRulePolicy(needSpeRulePolicy);
request.setPageNo(pageNo);
request.setRowPerPage(rowPerPage);
List<String> paraList = new ArrayList<String>();
paraList.add(agencyCode);
paraList.String(needSpePricePolicy));
paraList.String(needSpeRulePolicy));
paraList.String(pageNo));
paraList.String(rowPerPage));
paraList.add(securtyCode);
String sign = Sign(paraList).toLowerCase();
request.setSign(sign);
GetPolicyReply response = Policy(request);
String returnCode = ReturnCode();
if("s".equalsIgnoreCase(returnCode))
{
WsPolicyData[] data = PolicyDatas();
for(int i = 0 ; i < data.length ; i++)
{
System.out.println(data[i].getAirlineCode());
policy51BookService.savePolicy(data[i].convertToPolicy51book()); }
}
else if("f".equalsIgnoreCase(returnCode))
{
System.out.println("fail:"+ReturnMessage());
}
}service fault
catch (AxisFault e)
{
e.printStackTrace();
}
catch (RemoteException e)
{
e.printStackTrace();
}
catch (ServiceException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论