My nusopa php service located on link:
http://localhost/SOAP/soapWebService.php?wsdl
<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://localhost/soap/samplePHPService" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://localhost/soap/samplePHPService">
<types>
<xsd:schema targetNamespace="http://localhost/soap/samplePHPService">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/>
</xsd:schema>
</types>
<message name="wonderLocatedPlaceRequest">
<part name="name" type="xsd:string"/>
</message>
<message name="wonderLocatedPlaceResponse">
<part name="return" type="xsd:string"/>
</message>
<portType name="samplePHPServicePortType">
<operation name="wonderLocatedPlace">
<input message="tns:wonderLocatedPlaceRequest"/>
<output message="tns:wonderLocatedPlaceResponse"/>
</operation>
</portType>
<binding name="samplePHPServiceBinding" type="tns:samplePHPServicePortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="wonderLocatedPlace">
<soap:operation soapAction="http://localhost/SOAP/soapWebService.php/wonderLocatedPlace" style="rpc"/>
<input>
<soap:body use="literal" namespace=""/>
</input>
<output>
<soap:body use="literal" namespace=""/>
</output>
</operation>
</binding>
<service name="samplePHPService">
<port name="samplePHPServicePort" binding="tns:samplePHPServiceBinding">
<soap:address location="http://localhost/SOAP/soapWebService.php"/>
</port>
</service>
</definitions>
I make java classes by wsimport.exe and have tou class.
Next i create employe client:
public class Main {
public static void main(String[] args) throws MalformedURLException {
SamplePHPServicePortType stub;
//Generating stub to use the existing service
stub = new SamplePHPService().getSamplePHPServicePort();
//Calling the existing service with the stub
String place = stub.wonderLocatedPlace("Taj Mahal");
System.out.println(place);
}
}
And get exception:
Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: error in msg parsing:
xml was empty, didn't parse! Please see the server log to find more detail regarding exact cause of the failure.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:116)
at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy29.wonderLocatedPlace(Unknown Source)
at com.company.Main.main(Main.java:22)
Validity xml be sucsesseful, but have other problem.. What is it?
Related
I ran wsdl2java command using Apache CXF codegen plugin. Excerpt from my WSDL:
<!-- submitSMSv3 -->
<message name="submitSMSv3">
<part name="parameters" element="tns:submitSMSv3"></part>
<!--<part name="gdspHeader" element="tns:gdspHeader"></part>-->
</message>
<message name="submitSMSv3Response">
<part name="result" element="tns:submitSMSv3Response"></part>
</message>
<portType name="SMSv3">
<jaxws:bindings xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
<jaxws:enableWrapperStyle>true</jaxws:enableWrapperStyle>
</jaxws:bindings>
<operation name="SubmitSMSv3" parameterOrder="parameters">
<input message="tns:submitSMSv3"></input>
<output message="tns:submitSMSv3Response"></output>
</operation>
</portType>
<binding name="SubmitSMSv3PortBinding" type="tns:SMSv3">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"></soap:binding>
<operation name="SubmitSMSv3">
<soap:operation soapAction=""></soap:operation>
<input>
<soap:body use="literal" parts="parameters"></soap:body>
<!--<soap:header message="tns:submitSMSv3" part="gdspHeader" use="literal"></soap:header>-->
</input>
<output>
<soap:body use="literal"></soap:body>
</output>
</operation>
</binding>
<service name="SubmitSMSv3Service">
<port name="SubmitSMSv3Port" binding="tns:SubmitSMSv3PortBinding">
<soap:address location="http://localhost:${HttpDefaultPort}/GDSPWebServices/SMSv3Service"></soap:address>
</port>
</service>
When I invoke the service, my SOAP body looks like this:
<soap:Body>
<ns1:submitSMSv3 xmlns:ns1="http://ws.gdsp.vodafone.com/">
<ns2:arg0 xmlns:ns2="http://ws.gdsp.vodafone.com/">
<deviceId>xxxxxx</deviceId>
<messageData></messageData>
<messageType>Text</messageType>
</ns2:arg0>
</ns1:submitSMSv3>
</soap:Body>
But I don't want the code as it fails the web call, I want my soap body to look like this instead:
<soap:Body>
<ns1:submitSMSv3 xmlns:ns1="http://ws.gdsp.vodafone.com/">
<deviceId>xxxxxxx</deviceId>
<messageData></messageData>
<messageType>Text</messageType>
</ns1:submitSMSv3>
</soap:Body>
I'm not sure what to do in order to get it to be this way as I know this way works.
after many of difficulties with the POJO messaging format, I opted to use PAYLOAD and now everything is working as designed. I had to add a processor for the request and the response but it now works.
I have a created a simple Login Webservice in Java and I am calling it from the Android code. I am passing two String Parameters to the Webservice. But they become null in the Webservice.
WebService Code :
public boolean authenicateUser(#WebParam(name="username")String username,
#WebParam(name="password")String password) {
System.out.println("Inside Authenticae USER+=========="+name+"-----"+Password);//This becomes null and null
final String LOGIN_SQL="SELECT * FROM UserDetails WHERE UserName=? and Password=?";
The Web service is hosted on Localhost Tomcat server
Android Server Request :
private static String NAMESPACE = "http://src.AndroidExample.Nagesh.com/";
private static String URL = "http://192.168.56.1:8080/AndroidLoginWS/LoginWebService?wsdl";
private static String SOAP_ACTION = "http://src.AndroidExample.Nagesh.com/";
Systerequest=new SoapObject(NAMESPACE,WebMethodName);
System.out.println("Values before calling WS"+user.UserName+"------"+user.Password);
request.addProperty("username", user.UserName);
request.addProperty("password",user.Password);
return request;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION + WebMethodName, envelope);
System.out.println("INside InvokeLoginWS==========RETURNED.................");
SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
loginStatus = Boolean.parseBoolean(response.toString());
The WSDL file is :
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!--
Published by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b.
-->
<!--
Generated by JAX-WS RI (http://jax-ws.java.net). RI's version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b.
-->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://src.AndroidExample.Nagesh.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://src.AndroidExample.Nagesh.com/" name="LoginService">
<types>
<xsd:schema>
<xsd:import namespace="http://src.AndroidExample.Nagesh.com/" schemaLocation="http://192.168.56.1:8080/AndroidLoginWS/LoginWebService?xsd=1"/>
</xsd:schema>
</types>
<message name="register">
<part name="parameters" element="tns:register"/>
</message>
<message name="registerResponse">
<part name="parameters" element="tns:registerResponse"/>
</message>
<message name="authenicateUser">
<part name="parameters" element="tns:authenicateUser"/>
</message>
<message name="authenicateUserResponse">
<part name="parameters" element="tns:authenicateUserResponse"/>
</message>
<portType name="LoginMethods">
<operation name="register">
<input wsam:Action="http://src.AndroidExample.Nagesh.com/LoginMethods/registerRequest" message="tns:register"/>
<output wsam:Action="http://src.AndroidExample.Nagesh.com/LoginMethods/registerResponse" message="tns:registerResponse"/>
</operation>
<operation name="authenicateUser">
<input wsam:Action="http://src.AndroidExample.Nagesh.com/LoginMethods/authenicateUserRequest" message="tns:authenicateUser"/>
<output wsam:Action="http://src.AndroidExample.Nagesh.com/LoginMethods/authenicateUserResponse" message="tns:authenicateUserResponse"/>
</operation>
</portType>
<binding name="LoginWSPortBinding" type="tns:LoginMethods">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="register">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="authenicateUser">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="LoginService">
<port name="LoginWSPort" binding="tns:LoginWSPortBinding">
<soap:address location="http://192.168.56.1:8080/AndroidLoginWS/LoginWebService"/>
</port>
</service>
</definitions>
I am new to both Android and Creating Web Service. I tried many other solution. But it does not seems to work.
I found the anser for the question. I opened the xsd schema from the wdsl. It was having the parameters as arg0 and arg1 only,though I have given the #WebParam annotation. I changed it in the request, the parameter is getting passed correctly.
final String LOGIN_SQL="SELECT * FROM UserDetails WHERE UserName=? and Password=?";
request.addProperty("name", user.UserName);
request.addProperty("Password",user.Password);
// try to change name to UserName
i have create a web service to add two numbers using netbeans...and i am getting the following response
SOAP Response
<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:AddResponse xmlns:ns2="http://calculator.me.org/">
<return>9</return>
</ns2:AddResponse>
</S:Body>
</S:Envelope>
Bu i need to generate the soap response xml of the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<CalculatedValue>9</CalculatedValue>
<response>
my java code:
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;
/**
*
* #author User
*/
#WebService(serviceName = "CalculatorWS")
#Stateless()
public class CalculatorWS {
/**
* This is a sample web service operation
*/
#WebMethod(operationName = "hello")
public String hello(#WebParam(name = "name") String txt) {
return "<a>" + txt + "</a>";
}
/**
* Web service operation
*/
#WebMethod(operationName = "Add")
public int Add(#WebParam(name = "i") int i, #WebParam(name = "j") int j) {
//TODO write your implementation code here:
int k=i+j;
return k;
}
}
wsdl:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is Metro/2.1.1-b09 (branches/2.1-6834; 2011-07-16T17:14:48+0000) JAXWS-RI/2.2.5-promoted-b04 JAXWS/2.2. -->
<definitions targetNamespace="http://calculator.me.org/" name="CalculatorWS" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:tns="http://calculator.me.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<types>
<xsd:schema>
<xsd:import namespace="http://calculator.me.org/" schemaLocation="CalculatorWS_schema1.xsd"/>
</xsd:schema>
</types>
<message name="hello">
<part name="parameters" element="tns:hello"/>
</message>
<message name="helloResponse">
<part name="parameters" element="tns:helloResponse"/>
</message>
<message name="Add">
<part name="parameters" element="tns:Add"/>
</message>
<message name="AddResponse">
<part name="parameters" element="tns:AddResponse"/>
</message>
<portType name="CalculatorWS">
<operation name="hello">
<input wsam:Action="http://calculator.me.org/CalculatorWS/helloRequest" message="tns:hello"/>
<output wsam:Action="http://calculator.me.org/CalculatorWS/helloResponse" message="tns:helloResponse"/>
</operation>
<operation name="Add">
<input wsam:Action="http://calculator.me.org/CalculatorWS/AddRequest" message="tns:Add"/>
<output wsam:Action="http://calculator.me.org/CalculatorWS/AddResponse" message="tns:AddResponse"/>
</operation>
</portType>
<binding name="CalculatorWSPortBinding" type="tns:CalculatorWS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="hello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
<operation name="Add">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CalculatorWS">
<port name="CalculatorWSPort" binding="tns:CalculatorWSPortBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL"/>
</port>
</service>
</definitions>
i searched a lot on this....but didn't get any answer.I found a similar post in stackoverflow with no correct answer.How to generate that particular soap response using the web-service?
It's not possible to get a reply like the one you posted. By definition a SOAP document (or message) must contain an Envelope and at least the Body element. See more in the SOAP specification.
Your only control is over the contents of the Body element, by specifying the operation style to be RPC (remote procedure call) or document (plain XML).
Is it possible to configure the location (schemaLocation and soap:address location) in a JAX-WS WSDL?
When I deploy the sample below, 'servername' would be localhost and 'serverport' would be the local port number for the web application.
However, I want to reconfigure these to be a proxy servername and serverport which redirects to the service. Is this possible and how would I achieve it?
The deployment environment is Tomcat and Apache.
I have the following service class:
#WebService
public class AuthenticationService {
....
public AuthenticationService(){}
#WebMethod
public AuthenticationResult checkAuthentication(
#WebParam(name = "authentication") Authentication authentication,
#WebParam(name = "privilege") Privilege privilege) {
....
}
}
When ran, the WSDL looks like this:
<definitions targetNamespace="http://authentication.service.ws.ijs/" name="AuthenticationServiceService">
<types>
<xsd:schema>
<xsd:import namespace="http://authentication.service.ws.ijs/" schemaLocation="http://servername:serverport/WebAppName/AuthenticationService?xsd=1"/>
</xsd:schema>
</types>
<message name="checkAuthentication">
<part name="parameters" element="tns:checkAuthentication"/>
</message>
<message name="checkAuthenticationResponse">
<part name="parameters" element="tns:checkAuthenticationResponse"/>
</message>
<portType name="AuthenticationService">
<operation name="checkAuthentication">
<input wsam:Action="http://authentication.service.ws.ijs/AuthenticationService/checkAuthenticationRequest" message="tns:checkAuthentication"/>
<output wsam:Action="http://authentication.service.ws.ijs/AuthenticationService/checkAuthenticationResponse" message="tns:checkAuthenticationResponse"/>
</operation>
</portType>
<binding name="AuthenticationServicePortBinding" type="tns:AuthenticationService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="checkAuthentication">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="AuthenticationServiceService">
<port name="AuthenticationServicePort" binding="tns:AuthenticationServicePortBinding">
<soap:address location="http://servername:serverport/WebAppName/AuthenticationService"/>
</port>
</service>
</definitions>
Any help would be greatly appreciated.
If you keep the original hostname in your request (e.g use ProxyPreserveHost On if you use mod_proxy) this should fix your URLs, if you use the same protocol. You may still have problems if your proxy switches between https and http.
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: A required header representing a Message Addressing Property is not present
what i am missing? i add wdsl-addressing programatically:
wsbp.setOutboundHeaders( new StringHeader(WS_ADDR_VER.messageIDTag, uuid), replyTo.createHeader(WS_ADDR_VER.replyToTag));
i am using jdeveloper 11g
CODE:
asyncNarociloServisService = new AsyncNarociloServisService();
AsyncNarociloServis asyncNarociloServis = asyncNarociloServisService.getAsyncNarociloServisPort();
// Get the request context to set the outgoing addressing properties
WSBindingProvider wsbp = (WSBindingProvider)asyncNarociloServis;
WSEndpointReference replyTo = new WSEndpointReference("http://84.255.215.133:7101/TestniWS-TestniWS-context-root/AsyncNarociloServisResponseImplPort", WS_ADDR_VER);
String uuid = "uuid:" + UUID.randomUUID();
wsbp.setOutboundHeaders( new StringHeader(WS_ADDR_VER.messageIDTag, uuid), replyTo.createHeader(WS_ADDR_VER.replyToTag));
WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<definitions
name="AsyncNarociloServisService"
targetNamespace="http://www.xxx.si/narocilowsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/"
xmlns:tns="http://www.xxx.si/narocilowsdl"
xmlns:nar="http://www.xxx.si/narocilo"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:pov="http://www.xxx.si/povratnica"
>
<plnk:partnerLinkType name="AsyncNarociloServis">
<plnk:role name="AsyncNarociloServisProvider">
<plnk:portType name="tns:AsyncNarociloServis"/>
</plnk:role>
<plnk:role name="AsyncNarociloServisRequestor">
<plnk:portType name="tns:AsyncNarociloServisResponse"/>
</plnk:role>
</plnk:partnerLinkType>
<types>
<xsd:schema>
<xsd:import namespace="http://www.xxx.si/narocilo" schemaLocation="narocilo.xsd"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://www.xxx.si/povratnica" schemaLocation="povratnica.xsd"/>
</xsd:schema>
</types>
<message name="obdelajNarociloResponse">
<part name="parameters" element="pov:povratnica"/>
</message>
<message name="obdelajNarocilo">
<part name="parameters" element="nar:narocilo"/>
</message>
<portType name="AsyncNarociloServisResponse">
<operation name="obdelajNarociloOperationResponse">
<input message="tns:obdelajNarociloResponse"/>
</operation>
</portType>
<portType name="AsyncNarociloServis">
<operation name="obdelajNarociloOperation">
<input message="tns:obdelajNarocilo"/>
</operation>
</portType>
<binding name="AsyncNarociloServisResponsePortBinding" type="tns:AsyncNarociloServisResponse">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="obdelajNarociloOperationResponse">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
</operation>
</binding>
<binding name="AsyncNarociloServisPortBinding" type="tns:AsyncNarociloServis">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="obdelajNarociloOperation">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
</operation>
</binding>
<service name="AsyncNarociloServisService">
<port name="AsyncNarociloServisPort" binding="tns:AsyncNarociloServisPortBinding">
<soap:address location="http://www.xxx.si:9088/ServicesG/services/AsyncNarociloServisPort"/>
</port>
</service>
</definitions>
EDIT:
request
<S:Header>
<To xmlns="http://www.w3.org/2005/08/addressing">??</To>
<Action xmlns="http://www.w3.org/2005/08/addressing">??</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">uuid:c839d6f4-2c33-4f5b-b001-7ce9869a3aa3</MessageID>
<wsa:ReplyTo xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>http://84.255.215.133:7101/TestniWS-TestniWS-context-root/AsyncNarociloServisResponseImplPort</wsa:Address>
</wsa:ReplyTo>
</S:Header>
<S:Body>
what to be in ??
I think you should add a WS-Adressing header.
I think that's what the message says.
I don't know what's the framework you use for your Web Service call but here is an example using the CXF as framework: http://cxf.apache.org/docs/ws-addressing.html.
Maybe take a look at this article: http://log.illsley.org/2006/10/05/a-required-header-representing-a-message-addressing-property-is-not-present/.
You can try something like:
<Action xmlns="http://www.w3.org/2005/08/addressing">http://www.kemofarmacija.si/narocilowsdl:obdelajNarociloOperation</Action>
<MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:8ff3f2f0-6548-4411-8075-98af3cc23a1b</MessageID>
<To xmlns="http://www.w3.org/2005/08/addressing">http://elona2.kemofarmacija.si:9088/ServicesG/services/AsyncNarociloServisPort</To>
<ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
<Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
</ReplyTo>