Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

AXIS XML calling .Net Web Service

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am attempting to call a very basic "HelloWorld" .Net WS using AXIS. The XML submitted from my AXIS client looks like

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:HelloWorld soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://tempuri.org/">
<p_name xsi:type="xsd:string">John</p_name>
</ns1:HelloWorld>
</soapenv:Body>
</soapenv:Envelope>

While this invokes the service it does not seem to pass the parameter in. I assumed this was because the p_name parameter was not qualified so when I manually modify the XML to

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:HelloWorld xmlns:ns1="http://tempuri.org/">
<ns1 _name xsi:type="xsd:string">John</ns1 _name>
</ns1:HelloWorld>
</soap:Body>
</soap:Envelope>

and submit this via a SOAP Tool I have it works fine. My question is how do I qualify the parameter with the ns1: qualification in code?

Also do child entities not inherit the namespace of their parent? i.e. Should the p_name parameter need qualification? (obviously it does but I don't really understand why)

Any help greatly appreciated.

Java Source

/*
* Main.java
*
* Created on 14 March 2006, 20:17
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/

package javaapplication1;


import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import javax.xml.namespace.QName;

/**
*
* @author
*/
public class Main {

/** Creates a new instance of Main */
public Main() {}

/**
* @param args the command line arguments
*/
public static void main(String [] args) {
try {
String endpoint = "http://localhost:8090/com.company.AXISInterOp/Service1.asmx";

Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new java.net.URL(endpoint) );

call.setUseSOAPAction(true);
call.setSOAPActionURI("http://tempuri.org/HelloWorld");
call.setOperationName(new QName("http://tempuri.org/", "HelloWorld") );

call.addParameter("p_name",
org.apache.axis.Constants.XSD_STRING,
javax.xml.rpc.ParameterMode.IN);
call.setReturnType(org.apache.axis.Constants.XSD_STRING);

String ret = (String) call.invoke( new Object[] { new String("John") } );


System.out.println("Sent 'John!', got '" + ret + "'");
} catch (Exception e) {
System.err.println(e.toString());
}
}
}
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic