2014年5月26日星期一

CXF WebService configuration-related , in detail

Now there is a project with CXF WebService service provided

As the beginner, it took more than one day to achieve the function , the following is my server code
interfaces:

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

@WebService
public interface TbSysUserinfoFor4AWebService {
@WebMethod
public String UpdateAppAcctSoap(@WebParam(name = "requestInfo") String requestInfo);
}

achieve :

@Service("userinfoManageFor4A")
@WebService(endpointInterface="service.tbSysUserinfoFor4AService.TbSysUserinfoFor4AWebService")
public class TbSysUserinfoFor4AWebServiceImpl implements
TbSysUserinfoFor4AWebService {
@SuppressWarnings("finally")
@Override
public String UpdateAppAcctSoap(String requestInfo) {
                 // 具体实现略
                return xml;
        }
}

xml configuration:

<jaxws:server address="/userinfoManageFor4A" >
<jaxws:serviceBean>
<ref bean="userinfoManageFor4A"/>
</jaxws:serviceBean>
</jaxws:server>


I tested with the axis, the code below.

public class TestWebService {
@Test
public void testUserInfoWebService(){
                        String xml = "<?xml version='1.0' encoding='UTF-8'?>略</USERMODIFYREQ>";
String url = "http://localhost:8080/cloud/WebService/userinfoManageFor4A?wsdl";
String method = "UpdateAppAcctSoap";
String parameterName = "requestInfo";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(url);
QName qName = new QName("http://tbSysUserinfoFor4AService.service/", method);
// QName qName = new QName(method, method);
call.setOperationName(qName);
call.setUseSOAPAction(true);
call.addParameter(parameterName, XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
String msg = call.invoke(new Object[]{xml}).toString();
System.out.println(msg);
               }
}
ways to achieve access to the results and return to normal ;
service after starting up, with QName qName = new QName ("http://tbSysUserinfoFor4AService.service/", method)


with other systems in the FBI doing testing , I found the other side of the access method with my little test access the same way

FBI found the time to test each other's access method is QName qName = new QName (method, method); That is the other side of namespaceuri Qname parameters and parameters are the same behind a content in this way to visit my services can not always access

party system also provides WebService service , and the other I wrote a similar client code to access each other's services , with the QName qName = new QName (method, method); way to visit , but also a normal visit and return results

It seems that this approach is feasible , the difference should be the end of my service configuration might not reach each other's requirements

that CXF server how to configure it to allow two parameters Qname same content?

Please help me see how to achieve here , thank you !


------ Solution ------------------------------------ --------
the first parameter is the namespace , this value can be found in the screenshot wsdl oh .
when you publish the namespace and method names can be configured the same .
------ For reference only -------------------------------------- -


Thank you , find where the problem before it is a problem that namespace , I also give separate interfaces and implementation classes plus over targetNameSpace, have no effect

has not been added to both targetNameSpace parameters must be added here is we can .

Thank you for your reply

没有评论:

发表评论