I have an asp.net web service (.asmx) running on our server, it basically returns a result object which contains a list of users. The structure looks like this:
<?xml version="1.0" encoding="utf-8"?>
<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>
<getUsersResponse xmlns="http://www.mycompany.com/">
<getUsersResult>
<userList>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
</clsUser>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
</clsUser>
</userList>
<faultResponse>
<faultOccurred>boolean</faultOccurred>
<faultDescription>string</faultDescription>
</faultResponse>
</getUsersResult>
</getUsersResponse>
</soap:Body>
</soap:Envelope>
This works fine, but I would like to add a list to my clsUser class. So I would like to change it from this:
using System;
using System.Collections.Generic;
using System.Web;
[Serializable]
public class clsUser
{
public string firstName;
public string lastName;
public int idNUmber
}
To this:
using System;
using System.Collections.Generic;
using System.Web;
[Serializable]
public class clsUser
{
public string firstName;
public string lastName;
public int idNumber
public List<clsExtraData> extraDataList;
}
Where clsExtraData contains a few strings:
using System;
using System.Collections.Generic;
using System.Web;
[Serializable]
public class clsExtraData
{
public string description;
public string data;
}
So I would expect my structure to look something like the following:
<?xml version="1.0" encoding="utf-8"?>
<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>
<getUsersResponse xmlns="http://www.mycompany.com/">
<getUsersResult>
<userList>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList>
<description>string</description>
<data>string</data>
</extraDataList>
</clsUser>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList>
<description>string</description>
<data>string</data>
</extraDataList>
</clsUser>
</userList>
<faultResponse>
<faultOccurred>boolean</faultOccurred>
<faultDescription>string</faultDescription>
</faultResponse>
</getUsersResult>
</getUsersResponse>
</soap:Body>
</soap:Envelope>
But instead I get the following:
<?xml version="1.0" encoding="utf-8"?>
<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>
<getUsersResponse xmlns="http://www.mycompany.com/">
<getUsersResult>
<userList>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList xsi:nil="true" />
</clsUser>
<clsUser>
<firstName>string</firstName>
<lastName>string</lastName>
<idNumber>int</idNumber>
<extraDataList xsi:nil="true" />
</clsUser>
</userList>
<faultResponse>
<faultOccurred>boolean</faultOccurred>
<faultDescription>string</faultDescription>
</faultResponse>
</getUsersResult>
</getUsersResponse>
</soap:Body>
</soap:Envelope>
Our web service users will design their clients around this web service structure, if it's showing up with the <extraDataList xsi:nil="true" /> how will they know what fields to expect in the extraDataList? How can I get my web service structure looking as expected?
if you post the WSDL im pretty sure there is a link explaining the values and fields in extraDataList
Related
I have 2 modules, one describes api with just interfaces of controllers and second with implementations.
Example:
Resource interface:
#Path("/resource")
public interface Resource {
#POST
#Path("/getAll")
#Produces("application/json")
Response getAll();
Resource implementation:
#RequestScoped
#Path("/user")
public class ResourceImpl implements Resource {
#RolesAllowed({"admin"})
public Response getAll() {
When I login with user that has role "user", I'm not getting 401 or 403 error.
If I add #RolesAllowed({"admin"}) to interface, then it will work as expected. But I believe there should be other solution for it
I tried solution from this topic https://access.redhat.com/solutions/766483 but with no luck
My ejb.xml looks like so:
<ejb-jar
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
<enterprise-beans>
<message-driven>
*Queues describtion*
</message-driven>
</enterprise-beans>
<assembly-descriptor>
<method-permission>
<role-name>admin</role-name>
<method>
<ejb-name>ResourceImpl</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
</assembly-descriptor>
</ejb-jar>
I'm using Jboss EAP 7.2.9
Thanks in advance
Im creating a soap web service for our client and I need to change the response from:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<send_messageResponse xmlns="send_message_response">
<message_response>
<message_id>2001</message_id>
<description>sent</description>
<status>sent</status>
</message_response>
</send_messageResponse>
</soap:Body>
</soap:Envelope>
to
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<send_message_response xmlns="send_message_response">
<message_response>
<message_id>2001</message_id>
<description>sent</description>
<status>sent</status>
</message_response>
</send_messageResponse>
</soap:Body>
</soap:Envelope>
i've tried adding
[WebMethod]
[return: XmlElement("message_response")]
[SoapDocumentMethod("send_message", RequestNamespace = "urn", ResponseNamespace = "send_message_response", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
but still cant change the response. im also wondering if any have experience in creating the Outbound API of Oracle Field Service Cloud? Coz our client is oracle :)
In spring-data-jpa, the repository returns Page<T>, implementation classes is PageImpl<T>, then I can't use dozer to convert it, because the pageImpl has two methods: hasContent() and getContent(), dozer can't the analyze type.
PageRequest missing no parameter constructor, dozer can't convert too. My solution is to rewrite them, do you have a better way?
You need to create an extra class and map your page to it, here an example:
Spring configuration for Dozer : (exmaple : xml files are under src/main/resources/META-INF/dozer )
XML config file :
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dozer.sourceforge.net http://dozer.sourceforge.net/schema/beanmapping.xsd">
<mapping wildcard="true" type="one-way">
<class-a>com.comp.proj.domain.SrcClass
</class-a>
<class-b>com.comp.proj.model.DesClass
</class-b>
</mapping>
<mapping wildcard="false" type="one-way">
<class-a>org.springframework.data.domain.Page</class-a>
<class-b>com.comp.proj.model.PageResponse
</class-b>
<field>
<a>totalElements</a>
<b>totalElements</b>
</field>
<field>
<a>totalPages</a>
<b>totalPages</b>
</field>
<field>
<a>content</a>
<b>desClasses</b>
</field>
</mapping>
</mappings>
Spring configuration :
<bean class="org.dozer.spring.DozerBeanMapperFactoryBean">
<property name="mappingFiles" value="classpath:META-INF/dozer/*.xml" />
</bean>
Page Responce Class:
public class PageResponse {
private List<DesClass> desClasses;
private Integer totalPages;
private Integer totalElements;
//sertters and getters
}
Now in your controller just inject : Mapper
#Resource
Mapper mapper;
and Convert Your Page<SrcClass> page to PageResponse this way :
mapper.map(page,PageResponse.class);
First of all, I don't know how can config restful url request for spring webflow,
for example,how can I invoke my webflow when type address:
http://localhost/app/order/edit/1002
It's easy to write spring mvc controller to handle this,but in case of webflow, I don't know how to pass parameters.
Can anybody help me?
Thanks
Try reading request parameter like following.
It processes "http://example.com/message?messageId=3" but when rendering view, the URL changes to something like "http://example.com/message?execution=e1s1".
Flow code:
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<on-start>
<evaluate expression="FooWebFlowController.create(flowRequestContext)"
result="flowScope.fooModel"/>
</on-start>
<view-state id="view" model="fooModel" view="fooView">
</view-state>
</flow>
FooWebFlowController bean:
import org.springframework.webflow.execution.RequestContext;
#Component
public class FooWebFlowController {
#Autowired
private FooDAO fooDAO;
public Foo create(RequestContext requestContext) {
String messageId = requestContext.getRequestParameters().get("messageId")
Foo foo = fooDAO.findByMessagId(messageId);
return foo;
}
}
Is the RequestPathFlowExecutorArgumentHandler what you're looking for?
Flow executor argument handler that
extracts arguments from the request
path and exposes them in the URL path.
This allows for REST-style URLs to
launch flows in the general format:
http://${host}/${context
path}/${dispatcher path}/${flowId}
<bean id="flowController" class="org.springframework.webflow.executor.mvc.FlowController">
<property name="flowExecutor" ref="flowExecutor" />
<property name="argumentHandler">
<bean class="org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler" />
</property>
</bean>
SOAP Request<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header/>
<S:Body>
<ns2:deleteDataView xmlns:ns2="http://ws.$$$$$.#####.####.com/">
<identifier>5</identifier>
</ns2:deleteDataView>
</S:Body>
</S:Envelope>
SOAP Response<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:deleteDataViewResponse xmlns:ns2="http://ws.$$$$$.#####.####.com/">
<return>ERROR: A bug has been encountered,please try later</return>
</ns2:deleteDataViewResponse>
</S:Body>
</S:Envelope>
I want to read SOAP response in flex,am some what new to FLEX,pls help,even good resources will work.
Handling SOAP Response
<mx:WebService
id="userRequest"
wsdl="http://www.gnpcb.org/esv/share/soap/index.php?wsdl">
<mx:operation name="doPassageQuery" resultFormat="object"
fault="mx.controls.Alert.show(event.fault.faultString)"
result="showResult(event)"/>
</mx:WebService>
In the above code you are accessing your SOAP WebService, now you have the resultFormat is an Object and the result function is showResult()
private function showResult(e:ResultEvent):void
{
trace(e.result);
}
Resources
http://www.flexlive.net/?p=79