Java??ε???webservice???
???????????? ???????[ 2015/4/15 10:56:31 ] ????????Java webservice ???
????Java????WebService??????????Apache????axis.jar?????д??????????????Eclipse???????WebServiceClient???????????е?Proxy????е??á??????????????????????Eclipse?????????????Щ??
????1????д???????
packagecom.yudun.test;
importjava.rmi.RemoteException;
importorg.apache.axis.client.Call;
importorg.apache.axis.client.Service;
importorg.apache.axis.message.PrefixedQName;
importorg.apache.axis.message.SOAPHeaderElement;
importcom.cezanne.golden.user.Exception;
importcom.cezanne.golden.user.UserManagerServiceProxy;
importjavax.xml.namespace.QName;
importjava.net.MalformedURLException;
importjavax.xml.rpc.ServiceException;
importjavax.xml.soap.Name;
importjavax.xml.soap.SOAPException;
publicclasstestWebService{
publicstaticStringgetResult()throwsServiceException??MalformedURLException??RemoteException??SOAPException
{
//???WebService?????·??
Stringendpoint="WebService??????";
//????Service???
Serviceservice=newService();
//???Service???????Call?????
Callcall=(Call)service.createCall();
//??WebService?????·??????call??????.
call.setTargetEndpointAddress(newjava.net.URL(endpoint));//?Call???÷????λ??
//?????????????????????????SOAP??????
NameheaderName=newPrefixedQName(newQName("??????wsdl???targetNamespace???url"??"string_itemName"));
org.apache.axis.message.SOAPHeaderElementheader=newSOAPHeaderElement(headerName);
header.addTextNode("blablabla");
call.addHeader(header);
//SOAPHeaderElementsoapHeaderElement=newSOAPHeaderElement("??????wsdl???targetNamespace???url"??"SoapHeader");
//soapHeaderElement.setNamespaceURI("??????wsdl???targetNamespace???url");
//try
//{
//soapHeaderElement.addChildElement("string_itemName").setValue("blablabla");
//}
//catch(SOAPExceptione)
//{
//e.printStackTrace();
//}
//call.addHeader(soapHeaderElement);
//????WebService?????
org.apache.axis.description.OperationDescoper;
org.apache.axis.description.ParameterDescparam;
oper=neworg.apache.axis.description.OperationDesc();
oper.setName("opName");
param=neworg.apache.axis.description.ParameterDesc(newjavax.xml.namespace.QName(""??"arg0")??org.apache.axis.description.ParameterDesc.IN??newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema"??"string")??java.lang.String.class??false??false);
param.setOmittable(true);
oper.addParameter(param);
param=neworg.apache.axis.description.ParameterDesc(newjavax.xml.namespace.QName(""??"arg1")??org.apache.axis.description.ParameterDesc.IN??newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema"??"string")??java.lang.String.class??false??false);
param.setOmittable(true);
oper.addParameter(param);
param=neworg.apache.axis.description.ParameterDesc(newjavax.xml.namespace.QName(""??"arg2")??org.apache.axis.description.ParameterDesc.IN??newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema"??"string")??java.lang.String.class??false??false);
param.setOmittable(true);
oper.addParameter(param);
oper.setReturnType(newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema"??"string"));
oper.setReturnClass(java.lang.String.class);
oper.setReturnQName(newjavax.xml.namespace.QName(""??"return"));
oper.setStyle(org.apache.axis.constants.Style.WRAPPED);
oper.setUse(org.apache.axis.constants.Use.LITERAL);
oper.addFault(neworg.apache.axis.description.FaultDesc(
newjavax.xml.namespace.QName("??????wsdl???targetNamespace???url"??"Exception")??
"Exception"??
newjavax.xml.namespace.QName("??????wsdl???targetNamespace???url"??"Exception")??
true
));
call.setOperation(oper);
call.setOperationName(newjavax.xml.namespace.QName("??????wsdl???targetNamespace???url"??"opName"));
//????WebService?????????
Stringres=(String)call.invoke(newObject[]("arg0"??"arg1"));
System.out.println("===============");
returnres;
}
/**
*@paramargs
*/
publicstaticvoidmain(String[]args){
try{
System.out.println(getResult());
}catch(MalformedURLExceptione){
e.printStackTrace();
}catch(RemoteExceptione){
e.printStackTrace();
}catch(ServiceExceptione){
e.printStackTrace();
}catch(SOAPExceptione){
e.printStackTrace();
}
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11