Jump to content

understanding SOAP message structure


XSLTnewbie

Recommended Posts

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:main="http://main.soap.com/">   <soapenv:Header/>   <soapenv:Body>      <main:getMessage>         <arg0>abc</arg0>      </main:getMessage>   </soapenv:Body></soapenv:Envelope>

This is the SOAP request generated by soapUI for the web service I created. The webservice method looks like this :

	@Override	public String getMessage(String name) {		return "Your name is " + name;	}

What I want to ask is why does the parameter use the element <arg0> instead of <name> which is the variable name for the parameter in the method?

 

I'm using Java to generate the web service. Also, I'd like to know how to publish the webservice if I have more than one class for my service methods? I normally publish the webservice using this syntax:

Endpoint.publish("http://localhost:8080/myservice", new Webservice1());

what if I have another class called Webservice2 or Webservice3 and I want to publish it on localhost8080:/myservice too? I'll get "Address already in use".

Thanks

Link to comment
Share on other sites

 

 

What I want to ask is why does the parameter use the element <arg0> instead of <name> which is the variable name for the parameter in the method?

The names of the parameters are not important outside of the function definition. It's not necessary for the calling code to know the name that you use for the parameter, the only thing it needs to know is which parameter it is.

 

If you want to have multiple sets of functions that all respond on the same address then you'll need to make a master class that inherits from each of the other classes. You can't have any method names be the same in the different classes or that will be a problem, if it's going to work then each class needs unique methods so that it can route requests correctly. You can also change the URL to set up different web services on different URLs. Combining them into one is the same as creating one large web service, you're still not running multiple web services on one URL. A URL is a single web service, but that web service could be one which encapsulates several other services.

Link to comment
Share on other sites

hi, thanks for the response. But is it possible to actually get this display in the WSDL

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:main="http://main.soap.com/">   <soapenv:Header/>   <soapenv:Body>      <main:getMessage>         <Name>abc</Name>      </main:getMessage>   </soapenv:Body></soapenv:Envelope>

if it is, could you tell me how? which code should be added or modified?

thanks

Link to comment
Share on other sites

That's probably a question for someone familiar with SoapUI.

 

You can make the WSDL whatever you want. You can write that code yourself if you want to. The web service needs to be expecting it though, you need to write the web service to look at the SOAP envelope and process it a certain way. If a program like SoapUI is going to do that part for you then you're limited by whatever options the program gives you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...