Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Apache Axis Call's soap Envelope without xml processing instruction

Posted on 2006-03-29
7
Medium Priority
?
1,732 Views
Last Modified: 2012-08-13
Hi,

I have a Axis DII client that invokes a webservice. The request the service excepts looks like this:
<!--REQUEST.................-->
<env:Envelope  xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <env:Body>
  <n1:getCityLocals  xmlns:n1="http://www.pin.com/pcs/procs/v1">
   <CP xmlns="java:com.pin.pcs.procs/v1">
    <CPRC children="true" xmlns="">      
      <cpCode>1001</cpCode>
    </CPRC>
   </CP>  
</n1:getCityLocals  >  
</env:Body>
</env:Envelope>
<!------------------------------!>

What Call object creates from my code looks like this
<?xml version="1.0" encoding="UTF-8"?> ////////difference - added
<env:Envelope  xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <env:Body>
  <n1:getCityLocals  xmlns:n1="http://www.pin.com/pcs/procs/v1">
   <CP xmlns="java:com.pin.pcs.procs/v1">
    <CPRC children="true" xmlns="">      
      <cpCode>1001</cpCode>
    </CPRC>
   </CP>  
</n1:getCityLocals  >  
</env:Body>
</env:Envelope>

The service fails when I send this request. The only difference is, addition of xml declaration and exclusion of "xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/"

Here is my code: that creates Call and invokes the service
/****************************/
String endpoint =
             "http://localhost:8232/CPWS/CP";
        Service  service = new Service();
        Call call    = (Call) service.createCall();
       
        call.setProperty(Call.ENCODINGSTYLE_URI_PROPERTY, "http://schemas.xmlsoap.org/soap/encoding/");
        call.setOperationStyle(Style.DOCUMENT);
        call.setTargetEndpointAddress( new java.net.URL(endpoint) );
        call.setSOAPActionURI("");
        call.setOperation(new QName("http://www.pin.com/pcs/procs/v1"), "getCityLocals");
        call.setProperty("omit-xml-declaration", "true");
        String ret = (String) call.invoke(new Object[] { getDocument() } );
/****************************/

My question is how to remove the xml declaration and how to add soap encoding namespace to Soap Envelope. Call object creates this evelope. Any help is Greatly appreciated.

Thanks


0
Comment
Question by:dasvinay
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:vikraman_b
ID: 16327045
0
 

Author Comment

by:dasvinay
ID: 16328552
Vikraman,

Thank you for the quick response. Most of the tutorial's examples are of rpc style. I am looking for document/literal examples. I could use sun's jax-rpc library instead of apache Axis. But the question still remains. Is there a way to ignore xml processing instruction while creating an Envelope, like omit-xml-declaration etc in Document.

Thanks
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 16330252
Well, I prefer to create a proxy using WSDL 2 Java and use it instead - works good.
0
 

Author Comment

by:dasvinay
ID: 16332563
The dynamic proxy invocation works fine. I want to use DII because I don't want to put thirdparty jars in my application. What I am looking for is a small example of how to use dii for document/literal style. I tried with apache axis, The envlope is formed correctly, but with the xml declaration on top, which the service doesn't like.

Thanks for hlep..
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 2000 total points
ID: 16339454
This one has some sample code for various means in which you can invoke a web-service (DII, dynamic proxy, etc):

https://bpcatalog.dev.java.net/nonav/soa/standalone-client/
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question