public static void main (String [] args) throws Exception {
String wsdlUrl = "http://www.webxml.com.cn/webservices/chinatvprogramwebservice.asmx?wsdl";
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance ();
Client client = factory.createClient (wsdlUrl);
Object [] res = client.invoke ("getAreaString");
System.out.println (res [0]);
}
}
The above is my test code , television stations provide Web Services, a local not want to save the WSDL, run the above code error , seeking guidance.
------ Solution ---------------------------------------- ----
http://blog.csdn.net/chenghui0317/article/ details/9320053
try this. .
------ For reference only -------------------------------------- -
http://bbs.csdn.net/topics/390667364
- ----- For reference only ---------------------------------------
now only make use CXF it, what better way is not .
------ For reference only -------------------------------------- -
cxf there is a bug that does not recognize this thing
------ For reference only -------------------------------------- -
put that down to the local wsdl , and then generate the corresponding local class .
now is to dynamically call the method directly call WEBservice get the data it
------ For reference only -------------------- -------------------
not affect ah, and local wsdl file is not closed , is inside the url work. url is unchanged .
------ For reference only -------------------------------------- -
not know ah , seeking advice < br> ------ For reference only --------------------------------------- my URL is a remote URL, download his wsdl change under it ?
------ For reference only -------------------------------------- -
according to the above , modified the code
public class ClientText {
public static void main (String [] args) {
/ / this is to visit deployed cxf webservice client service with cxf
/ / do remember , access must be added the webservice cxf namespace, otherwise pass
/ / now another problem, pass the last parameter server does not receive
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance ();
org.apache.cxf.endpoint.Client client = dcf.createClient ("http://www.webxml.com .cn / webservices / chinatvprogramwebservice.asmx wsdl ")?;
/ / url to call the wsdl address webService
QName name = new QName ("http://www.webxml.com.cn/webservices/chinatvprogramwebservice.asmx/" , "getAlbumList");
/ / namespace is the namespace , methodName is the name of the method
String xmlStr = ""
+ " ;
+ " ;
+ " ;
+ " ;
+ " ;
+ " ;
+ " ;
+ " ;
/ / paramvalue parameter values
Object [] objects;
try {
objects = client.invoke (name, xmlStr);
/ / invoke web Service / / Output the result of calling
System.out.println (objects [0] toString ().);
} catch (Exception e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
}
}
run error undefined element declaration 's: schema'
tragedy ah ....
------ For reference only ---------------------------- -----------
in creating a client on an error
... client calls , I'm here also what configuration?
------ For reference only -------------------------------------- -
how you all can take over the line ?
------ For reference only ---------------------------------- -----
I changed the URL with the method ah , seeking guidance ..
------ For reference only -------------- -------------------------
you can Baidu undefined element declaration 's: schema'
http://blog.sina.com.cn/s/blog_4c925dca01014y3r.html
------ For reference only -------------------------------------- -
that I have read , this is it WSDL and then downloaded to the local modify the generated class .
hey ...
没有评论:
发表评论