Access the. NET WebService in the j2-based Environment

Source: Internet
Author: User

How can we access WebService through the use of kSOAP or which ws package can be directly used to support jsr172. It is troublesome to access the WebService created by. net. If jsr172 is supported, you can use wtk2.2 to directly generate a pile, that is, you can generate a stub and several Metadata classes to access WebService, but pay attention to the return type, if the WebService return type is not supported by wtk, the generation fails.
If jsr172 is not supported, kSOAP can be used for SOAP Protocol Resolution to complete WebService access. I tried ksoap2 and I don't know if it is always unsuccessful. I reported an error because there is a problem with xmlpull in kxml. The V11 class cannot be found. It seems that using ksoap2 will be a good choice to access. Net WebService, because it has built-in options supported by. net, you can configure RPC and net options. However, because it is unsuccessful, you cannot go to kSOAP to find a solution.
The example program of helloworld is used as a helloworld program. If the program fails, the httptransport class is transformed to compare the printed and received soap packets, it is found that the soap labels are inconsistent. I use. net WebService supports soap labels such as soapenc, and the use of kSOAP to call out the package is SOAP-ENC and so on. You can't change it manually. Modify the org. kSOAP. Soap. Java file to find the SOAP-ENC, change the SOAP-ENV to soapenc, soapenv, and so on. Check whether the entered soap package is less than the soap package required by. Net WebService. Org. kxml. parser. abstractxmlparser. there is a problem with the public void starttag (prefixmap, string namespace, string name) method in the Java file, where there is a do, while loop has a problem
Change
Do {
String P2 = current. getprefix ();
String NS = current. getnamespace ();
If (! NS. Equals (oldmap. getnamespace (P2 ))){
Attribute (p2.equals ("")? "Xmlns": ("xmlns:" + P2), NS );
}
Current = current. getprevious ();
}
While (current! = NULL & current! = Oldmap );
The original method does not write the information in the current prefixmap successor prefixmap, so the information in a tag is incomplete. There is still a problem running after modification. According to the returned content of the soap package, we found that there were two duplicate headers after transformation, which were checked as soap. there is a problem when initializing the prefixmap array in Java. The original method defines a baseprefixmap, and this prefixmap is used in the following protocols to construct it, therefore, the SOAP Headers of V11 and V12 are repeatedly modified by soapenv and soapenc.
Public static final prefixmap [] prefixmap = {
New prefixmap (New prefixmap
(Baseprefixmap, "XSD", xsd1999), "xsi", xsi1999 ),
New prefixmap (New prefixmap
(Prefixmap. Default, "XSD", XSD), "xsi", xsi), "Soap", ENV), "soapenc", ENC ),
New prefixmap (New prefixmap
(Prefixmap. Default, "XSD", XSD), "xsi", xsi), "Soap", env2001), "soapenc", enc2001 )};
That's all. Haha. However, an error occurs. The ENC protocol does not match the Env protocol. I used V12, or 2001, but I did not expect it to be correct. I used V11 to solve the problem, but it was not feasible to run it, so that the problem could not be solved, another problem occurs. The fault code returned by soap does not exist because soapaction does not exist. After comparison, it is found that this soapaction must be the same as that returned by soap. net WebService, and some are namespace + method, some are not. Tired, specify soapaction as namespace + method, for example, this soapaction is "http://ww.tmp.com/method", and that URL is http: // yourserver/yourservice. asmx; so that you can finally access it.
If you want to access. Net's WebService, I use [webmethod, soaprpcmethod] on each service method that needs to be accessed. If soaprpcmethod is not added, it cannot be used.
Finally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.