You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by cngyver <ce...@yahoo.com> on 2009/01/27 09:10:24 UTC

Axis2-1.4 JAX-WS annotated service namespace problem

Hello i've created an annotated service like below (it is in an .aar archive
uploaded to axis, not a single pojo file):
@WebService(name="IVRService", serviceName = "IVRService", 
		endpointInterface="com.akademi.ivr.service.IVRCallService", 
		targetNamespace="http://www.akademi-consulting.com.tr/services")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL)
public class IVRCallServiceImpl implements IVRCallService {	
	
	public CompanyCheckResult checkCompanyByPhoneNumber(String phone)
			throws IVRServiceException {
		try{ 			
			CompanyCheckResult result = new CompanyCheckResult();
			result.setStatusCode(0);
			result.setCompanyCode("sdfsdfewer");
			return result;
		}catch(Exception ex){
			
		}
		return null;
	}
}

when you call this checkCompanyByPhoneNumber method response SOAP is like
this:
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:checkCompanyByPhoneNumberResponse
xmlns:ns="http://www.akademi-consulting.com.tr/services">
      <ns:return xmlns:ax24="http://model.ivr.akademi.com/xsd"
xmlns:ax21="http://exception.ivr.akademi.com/xsd"
type="com.akademi.ivr.model.CompanyCheckResult">
        <ax24:companyCode>sdfsdfewer</ax24:companyCode>
        <ax24:statusCode>0</ax24:statusCode>
      </ns:return>
    </ns:checkCompanyByPhoneNumberResponse>
  </soapenv:Body>
</soapenv:Envelope>

there is no real problem here but i want the namespaces of elements to be
different than axis2 uses
so i add a few more annotations to class:
@WebService(name="IVRService", serviceName = "IVRService", 
		endpointInterface="com.akademi.ivr.service.IVRCallService", 
		targetNamespace="http://www.akademi-consulting.com.tr/services")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL)
public class IVRCallServiceImpl implements IVRCallService {	
	
	@WebMethod(operationName="checkCompanyByPhoneNumber", 
		
action="http://www.akademi-consulting.com.tr/services/ivr/checkCompanyByPhone")
	@RequestWrapper(localName="checkCompanyByPhoneNumber", 
			targetNamespace="http://www.akademi-consulting.com.tr/types/ivr")
	@WebResult(name="CompanyCheckResult",
			targetNamespace="http://www.akademi-consulting.com.tr/model/ivr")
	@ResponseWrapper(localName="checkCompanyByPhoneNumberResponse", 
			targetNamespace="http://www.akademi-consulting.com.tr/types/ivr")
	public CompanyCheckResult checkCompanyByPhoneNumber(String phone)
			throws IVRServiceException {
		try{ 			
			CompanyCheckResult result = new CompanyCheckResult();
			result.setStatusCode(0);
			result.setCompanyCode("sdfsdfewer");
			return result;
		}catch(Exception ex){
			
		}
		return null;
	}
}

now i expected the response look like this; ns and ax24 prefixes point to
new namespaces:
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:checkCompanyByPhoneNumberResponse 
      xmlns:ns="http://www.akademi-consulting.com.tr/types/ivr">
      <ns:return xmlns:ax24="http://www.akademi-consulting.com.tr/model/ivr" 
        xmlns:ax21="http://exception.ivr.akademi.com/xsd" 
        type="com.akademi.ivr.model.CompanyCheckResult">
        <ax24:companyCode>sdfsdfewer</ax24:companyCode>
        <ax24:statusCode>0</ax24:statusCode>
      </ns:return>
    </ns:checkCompanyByPhoneNumberResponse>
  </soapenv:Body>
</soapenv:Envelope>

but response is still like the first one.

What is the problem here ? I know annotations are processed because when i
view auto-generated wsdl, i see service namespace and action attributes are
correct. But, i can't make the namespaces as i wanted.
-- 
View this message in context: http://www.nabble.com/Axis2-1.4-JAX-WS-annotated-service-namespace-problem-tp21681159p21681159.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis2-1.4 JAX-WS annotated service namespace problem

Posted by cngyver <ce...@yahoo.com>.
I tried what happens if i use a wsdl. First without out wsdl:
The Service:

@WebService(
		name="IVRService", serviceName = "IVRService",
		targetNamespace="http://www.akademi-consulting.com.tr/services")
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT, 
		use=SOAPBinding.Use.LITERAL, 
		parameterStyle=ParameterStyle.WRAPPED)
public class IVRCallServiceImpl{	
	
	@WebMethod(operationName="checkCompanyByPhoneNumber")
	public CompanyCheckResult checkCompanyByPhoneNumber(String phone){
		try{
			//CompanyCheckResult result = dao.checkCompanyByPhoneNumber(phone);
			CompanyCheckResult result = new CompanyCheckResult();
			result.setStatusCode(0);
			result.setCompanyCode("sdfsdfewer");
			return result;
		}catch(Exception ex){
			
		}
		return null;
	}
}

and the response for method call:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
  <soapenv:Body>
    <ns:checkCompanyByPhoneNumberResponse
xmlns:ns="http://www.akademi-consulting.com.tr/services">
      <ns:return xmlns:ax21="http://model.ivr.akademi.com/xsd"
type="com.akademi.ivr.model.CompanyCheckResult">
        <ax21:companyCode>sdfsdfewer</ax21:companyCode>
        <ax21:statusCode>0</ax21:statusCode>
      </ns:return>
    </ns:checkCompanyByPhoneNumberResponse>
  </soapenv:Body>
</soapenv:Envelope>

now i got the auto-generated wsdl, changed namespaces to what i wanted, put
the wsdl into META-INF folder of .aar archive and told axis to use my wsdl. 
The service: same only wsdlLocation="META-INF/IVRService.wsdl" attribute is
added to annotation

the response: 
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <ns:checkCompanyByPhoneNumberResponse
xmlns:ns="http://www.akademi-consulting.com.tr/types/ivr">
      <ns:return type="com.akademi.ivr.model.CompanyCheckResult">
        <ns:companyCode>sdfsdfewer</ns:companyCode>
        <ns:statusCode>0</ns:statusCode>
      </ns:return>
    </ns:checkCompanyByPhoneNumberResponse>
  </soapenv:Body>
</soapenv:Envelope>

everything is ok, but namespace of the ns:return element which is different
from parent is missing. there is nothing i did here. my wsdl has only the
namespaces changed, not the structure but the response is missing it. so
client ( generated by axis2 itself again) fails because response does not
comply with my wsdl.  i've tried different combinations of annotations
(@WebResult, @ResponseWrapper etc) but i can't make this work.
original wsdl is this: 
http://www.nabble.com/file/p21682850/IVRService-orig.wsdl
IVRService-orig.wsdl 
and my wsdl :  http://www.nabble.com/file/p21682850/IVRService.wsdl
IVRService.wsdl 
-- 
View this message in context: http://www.nabble.com/Axis2-1.4-JAX-WS-annotated-service-namespace-problem-tp21681159p21682850.html
Sent from the Axis - User mailing list archive at Nabble.com.


Re: Axis2-1.4 JAX-WS annotated service namespace problem

Posted by cngyver <ce...@yahoo.com>.
I've made another try. this time i changed the response element in the wsdl:
<xs:element name="checkCompanyByPhoneNumberResponse">
  <xs:complexType>
    <xs:sequence>
	<xs:element minOccurs="0" name="return" nillable="true"
type="akam:CompanyCheckResult" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

become (return => result)

<xs:element name="checkCompanyByPhoneNumberResponse">
  <xs:complexType>
    <xs:sequence>
	<xs:element minOccurs="0" name="result" nillable="true"
type="akam:CompanyCheckResult" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

now the soap response should be (forget the namespace problem for now)

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <ns:checkCompanyByPhoneNumberResponse
xmlns:ns="http://www.akademi-consulting.com.tr/types/ivr">
      <ns:result type="com.akademi.ivr.model.CompanyCheckResult">
        <ns:companyCode>sdfsdfewer</ns:companyCode>
        <ns:statusCode>0</ns:statusCode>
      </ns:result>
    </ns:checkCompanyByPhoneNumberResponse>
  </soapenv:Body>
</soapenv:Envelope>

but i got the same response again.

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <ns:checkCompanyByPhoneNumberResponse
xmlns:ns="http://www.akademi-consulting.com.tr/types/ivr">
      <ns:return type="com.akademi.ivr.model.CompanyCheckResult">
        <ns:companyCode>sdfsdfewer</ns:companyCode>
        <ns:statusCode>0</ns:statusCode>
      </ns:return>
    </ns:checkCompanyByPhoneNumberResponse>
  </soapenv:Body>
</soapenv:Envelope>

i've changed the child element of response and put an annotation on the
method to tell this:
@WebResult(name="result", 
    targetNamespace="http://www.akademi-consulting.com.tr/model/ivr")
but axis returned the soap as the original soap response (with ns:return
child element). 
-- 
View this message in context: http://www.nabble.com/Axis2-1.4-JAX-WS-annotated-service-namespace-problem-tp21681159p21683442.html
Sent from the Axis - User mailing list archive at Nabble.com.