I am working on an API integration. I am using django==1.10.5 and python34. The app involves sending request from my server to another server which is connected through a VPN.
password = "xxxxxxxxxxxxxxxxx"
spid = "xxxxxxxxxxxxxxxxx"
serviceid = "xxxxxxxxxxxxxxxxx"
sendershortcode = "xxxxxxxxxxxxxxxxx"
initiator = "xxxxxxxxxxxxxxxxx"
initiator_password = "xxxxxxxxxxxxxxxxx"
recieveridentifier = "xxxxxxxxxxxxxxxxx"
body = """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://api-v1.gen.mm.vodafone.com/mminterface/request">
<soapenv:Header>
<tns:RequestSOAPHeader xmlns:tns="http://www.huawei.com/schema/osg/common/v2_1">
<tns:spId>"""+spid+"""</tns:spId>
<tns:serviceId>"""+serviceid+"""</tns:serviceId>
<tns:spPassword>"""+encoded_password+"""</tns:spPassword>
<tns:timeStamp>"""+reqTime+"""</tns:timeStamp>
</tns:RequestSOAPHeader>
</soapenv:Header>
<soapenv:Body>
<req:RequestMsg>
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<request xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/request">
<Transaction>
<CommandID>SalaryPayment</CommandID>
<LanguageCode></LanguageCode>
<OriginatorConversationID>"""+originator+"""</OriginatorConversationID>
<ConversationID></ConversationID>
<Remark></Remark>
<Parameters>
<Parameter>
<Key>Amount</Key>
<Value>200</Value>
</Parameter>
</Parameters>
<ReferenceData>
<ReferenceItem>
<Key>QueueTimeoutURL</Key>
<Value>http://138.197.41.74:80/user/test/</Value>
</ReferenceItem>
</ReferenceData>
<Timestamp>"""+reqTime+"""</Timestamp>
</Transaction>
<Identity>
<Caller>
<CallerType>2</CallerType>
<ThirdPartyID>broker_4</ThirdPartyID>
<Password>k+JtvqNV3eg=</Password>
<CheckSum>CheckSum0</CheckSum>
<ResultURL>http://138.197.41.74:80/results/B2C/</ResultURL>
</Caller>
<Initiator>
<IdentifierType>11</IdentifierType>
<Identifier>"""+initiator+"""</Identifier>
<SecurityCredential>YwBlXbjEFjh/UQ0cZhrk+4X9TxAIc3z8zf4rXZRZRLW32cm+c/lJYQ3ZFVThna+41x8EukAHZhuR44QiF5J1GF/9QaYwK1i1rIX2i/Fa9bRJ4fn/REYd/vE1/pUPn4GnfLib151RYQyO7KsLipLFk8Hr9SYq62MSrOxgyAd1bJXQ4SdEJwk0LtCZSTWBaZySbPJt/P0FBfG71kLkrP0P0pn1cuuuJoA3KJ5+RuX5WpsXR0HFFyyJFEwAlQ9oSmKW5fzCwEKMaKTKgScfyDXmhuiFZvrSmdV3H0o4Hhl17IQR8M1fwIk9JfxrSUqVRBrEqVKJrOOlSF/T7xLJTo0fpQ==</SecurityCredential>
<ShortCode>777133</ShortCode>
</Initiator>
<PrimaryParty>
<IdentifierType>4</IdentifierType>
<Identifier>777133</Identifier>
<ShortCode>777133</ShortCode>
</PrimaryParty>
<ReceiverParty>
<IdentifierType>1</IdentifierType>
<Identifier>"""+recieveridentifier+"""</Identifier>
<ShortCode>ShortCode1</ShortCode>
</ReceiverParty>
<AccessDevice>
<IdentifierType>1</IdentifierType>
<Identifier>Identifier3</Identifier>
</AccessDevice>
</Identity>
<KeyOwner>1</KeyOwner>
</request>]]></req:RequestMsg>
</soapenv:Body>
</soapenv:Envelope>"""
headers = {'content-type': 'Content-Type: text/xml; charset=utf-8'}
url = "http://xxx.xxx.xxxx.xxx:xxxx/mminterface/request"
response = requests.post(url=url, headers = headers, data = body)
#print (response.content)
respO = xmltodict.parse(response.content)
myresponse = json.dumps(respO)
This code works fine i am able to get a respose from the other server.
My question is the other server is sending some other data which am getting when i tcpdup response i.e. tcpdump -A -s 0 'src xxx.xxx.xxx.xxx and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
From doing this am getting this content.
<?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<res:ResultMsg xmlns:res="http://api-v1.gen.mm.vodafone.com/mminterface/result">
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Result xmlns="http://api-v1.gen.mm.vodafone.com/mminterface/result">
<ResultType>0</ResultType>
<ResultCode>0</ResultCode>
<ResultDesc>The service request has been accepted successfully.</ResultDesc>
<OriginatorConversationID>Z8MPEFVZ</OriginatorConversationID>
<ConversationID>AG_20170508_00006c8d2d96c6efbeab</ConversationID>
<TransactionID>LE80192FMG</TransactionID>
<ResultParameters>
<ResultParameter>
<Key>TransactionReceipt</Key>
<Value>LE80192FMG</Value>
</ResultParameter>
<ResultParameter>
<Key>TransactionAmount</Key>
<Value>200</Value></ResultParameter>
<ResultParameter>
<Key>B2CWorkingAccountAvailableFunds</Key>
<Value>0.00</Value>
</ResultParameter>
<ResultParameter>
<Key>B2CUtilityAccountAvailableFunds</Key>
<Value>5508.00</Value>
</ResultParameter>
<ResultParameter>
<Key>TransactionCompletedDateTime</Key>
<Value>08.05.2017 09:37:07</Value>
</ResultParameter>
<ResultParameter>
<Key>ReceiverPartyPublicName</Key>
<Value>254703381233</Value>
</ResultParameter>
<ResultParameter>
<Key>B2CChargesPaidAccountAvailableFu 06:38:49.685570 IP 196-201-214-127.safaricom.co.ke.60575 > mambowallet.http: Flags [P.], seq 1380:1741, ack 1, win 4380, length 361 ..gP...5 ..nds</Key>
<Value>-275.00</Value>
</ResultParameter>
<ResultParameter>
<Key>B2CRecipientIsRegisteredCustomer</Key>
<Value>N</Value></ResultParameter>
</ResultParameters>
<ReferenceData><ReferenceItem>
<Key>QueueTimeoutURL</Key>
<Value>http://138.197.41.74:80/user/test/</Value>
</ReferenceItem>
</ReferenceData>
</Result>]]>
</res:ResultMsg>
</soapenv:Body> </soapenv:Envelope>
Can someone help how i can get this content on the django view?
tcpdump image
you can do a tcpdump inside your python code using subprocess:
from subprocess import check_output
out = check_output(['tcpdump','args'])
you get the response in out and then you can work with it. for example:
out = check_output(['tcpdump', 'ether[0] & 1 = 0 and ip[16] >= 224'])
and you need to be root also
Related
I have a request with SOAPUI, work good:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:webservice">
<soapenv:Header/>
<soapenv:Body>
<urn:Notificacion>
<as_xml_peticion><![CDATA[<G_PETICION>
<CABECERA>
<NOTIFICADOR>API</NOTIFICADOR>
</CABECERA>
</G_PETICION>]]>
</as_xml_peticion>
But when I make a Axis2 Webservice client java with WSDL:
String xml = <![CDATA[<G_PETICION>
<CABECERA>
<NOTIFICADOR>API</NOTIFICADOR>
</CABECERA>
</G_PETICION>]]>;
tnofication.setAs_xml_peticion(xml);
notification.setNotificacion(tnofication);
WebserviceStub.NotificacionResponse response = proxy.notificacion(notification);
the response is:
Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset
What is the problem?
Searched thru serverfault.com, stackoverflow.com, apple.stackexchange.com, googled and still not getting far. Need someone to help.
I'm trying to get all vCards from iCloud accounts.
I'm starting from the plugin from Roundcube/CardDav.
From the articles such as:
stackoverflow.com/questions/24202551/manipulate-groups-in-icloud-with-carddav-protocol
sabre.io/dav/building-a-carddav-client/
sabre.io/dav/clients/osx-addressbook/
stackoverflow.com/questions/15111887/how-to-import-icloud-contacts-in-php#
tools.ietf.org/html/rfc6352#section-8.7.1
I managed to get the Principal, the Principal's address. But the last step of getting the card returns ContentLength of 0.
Here is what I do:
- use icloud email as username
- use icloud password
To get the Principal, using "https : / / contacts.icloud.com/" as URL, PROPFIND, DEPTH 0:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:">
<d:prop>
<d:current-user-principal/>
</d:prop>
</d:propfind>
Response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<multistatus xmlns="DAV:">
<response>
<href>/</href>
<propstat>
<prop>
<current-user-principal>
<href>/1331115018/principal/</href>
</current-user-principal>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
Next, here is what I do to get the home, using "https : / /contacts.icloud.com/1331115018/principal/", PROPFIND, DEPTH 0:
<?xml version="1.0" encoding="UTF-8"?>
<d:propfind xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:prop>
<card:addressbook-home-set/>
</d:prop>
</d:propfind>
Response:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<multistatus xmlns="DAV:">
<response>
<href>/1331115018/principal/</href>
<propstat>
<prop>
<addressbook-home-set xmlns="urn:ietf:params:xml:ns:carddav">
<href xmlns="DAV:">https://p44-contacts.icloud.com:443/1331115018/carddavhome/</href>
</addressbook-home-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
Finally, here is what I do to try to get all the vCards, using https : / / p44-contacts.icloud.com:443/1331115018/carddavhome/, REPORT, DEPTH 1:
<?xml version="1.0" encoding="utf-8" ?>
<C:addressbook-multiget xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:prop>
<D:getetag/>
<C:address-data>
<C:prop name="UID"/>
<C:prop name="EMAIL"/>
<C:prop name="FN"/>
</C:address-data>
</D:prop>
</C:addressbook-multiget>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:" xmlns:CD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/">
</multistatus>
or
<?xml version="1.0" encoding="utf-8" ?>
<C:addressbook-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:prop>
<D:getetag/>
<C:address-data>
<C:prop name="UID"/>
<C:prop name="EMAIL"/>
<C:prop name="FN"/>
</C:address-data>
</D:prop>
</C:addressbook-query>
Response:
<?xml version="1.0" encoding="UTF-8"?>
<multistatus xmlns="DAV:" xmlns:CD="urn:ietf:params:xml:ns:carddav" xmlns:CS="http://calendarserver.org/ns/">
<response>
<href>/1331115018/carddavhome/</href>
<propstat>
<prop> <getetag>"C=0#U=9123588c-8038-439c-a547-19c866d1ed06"</getetag>
<address-data xmlns="urn:ietf:params:xml:ns:carddav">
</address-data>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
or
<?xml version="1.0" encoding="utf-8" ?>
<C:addressbook-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
<D:prop>
<D:getetag/>
<C:address-data>
<C:prop name="UID"/>
<C:prop name="EMAIL"/>
<C:prop name="FN"/>
</C:address-data>
</D:prop>
<C:prop-filter name="EMAIL">
<C:text-match collation="i;unicode-casemap" match-type="equals">me</C:text-match>
</C:prop-filter>
</C:filter>
</C:addressbook-query>
Response:
"Didn't understand the report"
What do I have to do?
The CardDAV home (your https://p44-contacts.icloud.com:443/1331115018/carddavhome/) contains the CardDAV collections (aka the 'address books'), not the vCards (which contain contacts and contact groups). You need to take one more hop.
You can list the addressbook collections in the home using a regular PROPFIND Depth 1 and then query those for the contacts with the report you specify. Like so:
PROPFIND /1331115018/carddavhome/ HTTP/1.1
Depth: 1
Host: p44-contacts.icloud.com:443
Authorization: ...
Content-Type: text/xml; charset=utf-8
Content-Length: ...
<propfind xmlns="DAV:">
<prop>
<displayname />
<resourcetype />
</prop>
</propfind>
This returns you the list of all sub-collections in the CardDAV home collection.
The collections which have an addressbook resourcetype are CardDAV addressbook collections and can be queried using an addressbook-query or addressbook-multiget report, using a sync-report if that is supported (iCloud does) or again using a simple PROPFIND. Depends on what you want.
Given an address book collection URL a 'real' client would usually use a sync-report to grab the URLs of all changed objects if the server supports that, or just grab the URLs, Content-Type and ETags of all contained vCards using a PROPFIND as a fallback. For example:
PROPFIND /1331115018/carddavhome/contacts/ HTTP/1.1
Depth: 1
Host: p44-contacts.icloud.com:443
Authorization: ...
Content-Type: text/xml; charset=utf-8
Content-Length: ...
<propfind xmlns="DAV:">
<prop>
<getetag />
<getcontenttype />
</prop>
</propfind>
This gives you the URLs of all objects in the address book collection. Which you can then retrieve using simple GETs or a multiget REPORT.
BTW: In your addressbook-multiget REPORT you do not list any vCard URLs, hence the result set will always be empty ... You can read about multiget in RFC 6352.
Note: In iCloud there is usually just one addressbook collection in the home, but in other servers it is quite common to have multiple. Also in some servers the CalDAV and CardDAV homes are the same collection (i.e. remember to actually check the resourcetype of the sub-collections in the respective home collections).
This is a great introduction on CardDAV: Building a CardDAV client.
Or this one on YouTube: FOSDEM 2009 CalDAV.
<card:addressbook-multiget xmlns:d="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:prop>
<d:getetag />
<card:address-data />
</d:prop>
<d:href>/1331115018/carddavhome/card/vcard_UUID.vcf</d:href>
</card:addressbook-multiget>
Let try this in the REPORT Request.
Getting your credentials: https://github.com/muhlba91/icloud/blob/master/groovy_java/gui-2.1.0.zip! Keep in mind: https://support.apple.com/en-us/HT204397
Getting your vCards: https://github.com/andig/carddav2fb - just use the download command: php carddav2fb download yourdownload.vcf
all. I have next problem. I want to connect to mailbox with Impersonation rights. User Admin has Impersonation rights, and i know how to do it in C#.
I have next code:
ExchangeServiceBindingProxy *proxy = new ExchangeServiceBindingProxy(endpoint.c_str());
soap *pSoap = proxy->soap;
pSoap->userid = "Admin";
pSoap->passwd = "PASSWORD";
pSoap->ntlm_challenge = "";
pSoap->authrealm = "Ursa-Minor";
pSoap->ssl_flags = SOAP_SSL_NO_AUTHENTICATION;
pSoap->keep_alive = true;
soap_mode(pSoap,SOAP_IO_KEEPALIVE);
string smtp = "User1#no-such-email.com";
pSoap->header = new struct SOAP_ENV__Header();
pSoap->header->ns3__RequestServerVersion = new _ns3__RequestServerVersion();
pSoap->header->ns3__RequestServerVersion->Version = ns3__ExchangeVersionType__Exchange2007_USCORESP1;
if(!smtp.empty())
{
pSoap->header->ns3__ExchangeImpersonation = new ns3__ExchangeImpersonationType();
pSoap->header->ns3__ExchangeImpersonation->ConnectingSID = new ns3__ConnectingSIDType();
pSoap->header->ns3__ExchangeImpersonation->ConnectingSID->union_ConnectingSIDType.PrimarySmtpAddress = &smtp;
pSoap->header->ns3__ExchangeImpersonation->ConnectingSID->__union_ConnectingSIDType = 3;
}
As a resault i have this request:
POST /ews/Exchange.asmx HTTP/1.1
Host: 192.168.0.49
User-Agent: gSOAP/2.8
Content-Type: text/xml; charset=utf-8
Content-Length: 1093
Connection: keep-alive
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAGoAAAAYABgAggAAABoAGgBAAAAACAAIAFoAAAAIAAgAYgAAAAAAAACaAAAABYKBAk4ATwAtAFMAVQBDAEgALQBFAE0AQQBJAEwASQB2AGEAbgBJAHYAYQBuAKEcAIkJWxEWBsuOv7MjtBpHLDWAL8JCTJ28+8Uotrb6QFrMa88HavXFTG1ddTR1VQ==
SOAPAction: "http://schemas.microsoft.com/exchange/services/2006/messages/GetFolder"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns3="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/messages">
<SOAP-ENV:Header>
<ns3:ExchangeImpersonation SOAP-ENV:mustUnderstand="1">
<ns3:ConnectingSID>
<ns3:PrimarySmtpAddress>User1#no-such-email.com</ns3:PrimarySmtpAddress>
</ns3:ConnectingSID>
</ns3:ExchangeImpersonation>
<ns3:RequestServerVersion SOAP-ENV:mustUnderstand="1" Version="Exchange2007_SP1"></ns3:RequestServerVersion></SOAP-ENV:Header><SOAP-ENV:Body><ns1:GetFolder xsi:type="ns1:GetFolderType"><ns1:FolderShape><ns3:BaseShape>AllProperties</ns3:BaseShape></ns1:FolderShape><ns1:FolderIds><ns3:DistinguishedFolderId Id="msgfolderroot" xsi:type="ns3:DistinguishedFolderIdType"></ns3:DistinguishedFolderId></ns1:FolderIds></ns1:GetFolder></SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It seems legit, but server response return error:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/exchange/services/2006/types">a:ErrorInternalServerError</faultcode>
<faultstring xml:lang="en-US">An internal server error occurred. The operation failed.</faultstring>
<detail>
<e:ResponseCode xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">ErrorInternalServerError</e:ResponseCode>
<e:Message xmlns:e="http://schemas.microsoft.com/exchange/services/2006/errors">An internal server error occurred. The operation failed.</e:Message>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
ns3:ExchangeImpersonation> !!! THERE IS SOMETHING WRONG
<ns3:RequestServerVersion SOAP-ENV:mustUnderstand="1" Version="Exchange2007_SP1"></ns3:RequestServerVersion>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:GetFolder xsi:type="ns1:GetFolderType">
<ns1:FolderShape><ns3:BaseShape>AllProperties</ns3:BaseShape></ns1:FolderShape>
<ns1:FolderIds>
<ns3:DistinguishedFolderId Id="msgfolderroot" xsi:type="ns3:DistinguishedFolderIdType"></ns3:DistinguishedFolderId>
</ns1:FolderIds>
</ns1:GetFolder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response even doesn`t have well formed xml.
Well, i don`t know how to solve this problem at this moment.
To remove the mustunderstand attribute from the wsdl2h-generated source code declarations that produces the SOAP Header, use wsdl2h option -k.
This is an old question, but I had a little update on it: To those that may be experiencing issues with mustunderstand appearing due to using some gsoap plugin (for me it was with the wsse plugin, I know mustunderstand is part of that standard, but the service I am calling does not)
Anyway, to solve this I edited the header files in gsoap/import to remove the mustunderstand parts. This stopped the wsse header having mustunderstand included.
My Flex application properly call a web service but it does not populate the drop down box.
Based on my researches the problem is with the namespaces, but still not sure how to solve it.
Once I run the application the drop down box is empty.
My java code
package com.Services;
import com.classes.*;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebResult;
#WebService (name="Hellos",
targetNamespace="http://localhost:8081/Mywebservice2/services/Hellos")
public class Hellos {
#WebMethod
public #WebResult (name="customers",partName="customers") Customer[] mycustomers()
{
System.out.println("Retriving customers....");
Customer[] cus = new Customer[2];
cus[0] = new Customer("Jack", 28);
cus[1] = new Customer("Ben", 29);
return cus;
}
}
The network monitor feature of the flex application shows the response is as following
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Transfer-Encoding: chunked
Date: Thu, 10 Jan 2013 04:23:55 GMT
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<mycustomersResponse xmlns="http://Services.com">
<mycustomersReturn>
<age>28</age>
<name>Jack</name>
</mycustomersReturn>
<mycustomersReturn>
<age>29</age>
<name>Ben</name>
</mycustomersReturn>
</mycustomersResponse>
</soapenv:Body>
</soapenv:Envelope>
my flex code is as following
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function
dropDownList2_creationCompleteHandler(event:FlexEvent):void
{
mycustomersResult2.token = hellos.mycustomers();
}
]]>
</fx:Script>
<fx:Declarations>
<hellos:Hellos id="hellos" fault="Alert.show(event.fault.faultString + '\n'
+ event.fault.faultDetail)"
showBusyCursor="true"/>
<s:CallResponder id="mycustomersResult2"/>
</fx:Declarations>
<s:FormItem label="Label">
<s:DropDownList id="dropDownList2"
creationComplete="dropDownList2_creationCompleteHandler(event)"
labelField="age">
<s:AsyncListView list="{mycustomersResult2.lastResult}"/>
</s:DropDownList>
</s:FormItem>
When I change
<s:AsyncListView list="{mycustomersResult2.lastResult}"/>
to
<s:AsyncListView list="
{mycustomersResult2.lastResult.mycustomersResponse.mycustomersReturn}"/>
it gives the following error
Error: Unknown Property: 'mycustomersResponse'.
at mx.collections::ListCollectionView/http://www.adobe.com/2006/actionscript/flash/proxy::getProperty()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\collections\ListCollectionView.as:870]
at mx.binding::PropertyWatcher/updateProperty()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\PropertyWatcher.as:338]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.binding::Watcher/wrapUpdate()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\Watcher.as:192]
at mx.binding::PropertyWatcher/updateParent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\PropertyWatcher.as:239]
at mx.binding::Watcher/updateChildren()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\Watcher.as:138]
at mx.binding::PropertyWatcher/updateProperty()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\PropertyWatcher.as:347]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.binding::Watcher/wrapUpdate()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\Watcher.as:192]
at mx.binding::PropertyWatcher/eventHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\binding\PropertyWatcher.as:375]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.rpc::CallResponder/set lastResult()
at mx.rpc::CallResponder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\CallResponder.as:120]
at mx.rpc::AsyncToken/http://www.adobe.com/2006/flex/mx/internal::applyResult()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncToken.as:239]
at mx.rpc.events::ResultEvent/http://www.adobe.com/2006/flex/mx/internal::callTokenResponders()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\events\ResultEvent.as:207]
at mx.rpc::AbstractOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractOperation.as:244]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:318]
at mx.rpc::Responder/result()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\Responder.as:56]
at mx.rpc::AsyncRequest/acknowledge()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:84]
at DirectHTTPMessageResponder/completeHandler()[E:\dev\4.5.1\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:451]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
It seems like problem with namespace for response xml format:
<mycustomersResponse xmlns="http://Services.com">
Just write anywhere in you code :
namespace ns = "http://Services.com";
use namespace ns;
I have written demo with given xml:
var xml:XML = <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<mycustomersResponse xmlns="http://Services.com">
<mycustomersReturn>
<age>28</age>
<name>Jack</name>
</mycustomersReturn>
<mycustomersReturn>
<age>29</age>
<name>Ben</name>
</mycustomersReturn>
</mycustomersResponse>
</soapenv:Body>
</soapenv:Envelope>
namespace ns = "http://Services.com";
use namespace ns;
namespace ns_soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
use namespace ns_soapenv;
trace(xml.Body.mycustomersResponse.mycustomersReturn.length()); //output 2
It is parsed good. Hope it would helpful.
You don't have to parse it, the WebService class does it for you.
<s:WebService result=" soapResultHandler(event) ">
<!-- do stuff here -->
</s:WebService>
<fx:Script>
<![CDATA[
private function soapResultHandler( e:ResultEvent ):void {
//do stuff to e.result in here
}
]]>
</fx:Script>
The ResultEvent.result object is the XML automatically parsed into a single dynamic Object. You can easily loop through that to get whatever details you need. It is worth noting that if a single level of the XML document has multiple instances of the same tag name, there will be an ArrayCollection (not Array, mind) rather than a series of those objects.
See the ResultEvent#result LiveDocs
I'm trying to create a WS, deploy it in Tomcat, inside a webapplication and use a stub to call it.
I'm using this interface as a base for the WSDL:
package com.at.iscrizio.ws.services;
public interface SalutareService {
public String sayciao(String name);
}
and this script to generate the wsdl file, the server and deploy files and the client-side files:
set WSDL_FILE=SalutareService.wsdl
set TO_WSDL=%AXIS2_HOME%/bin/java2wsdl.bat
set TO_JAVA=%AXIS2_HOME%/bin/wsdl2java.bat
set CLASS=com.at.iscrizio.ws.services.SalutareService
set SOAP_ADDR=http://localhost:9090/Iscrizio/services/SalutareServiceEx
call %TO_WSDL% -cp build/classes -o ./wsdl -of %WSDL_FILE% -cn %CLASS% -l %SOAP_ADDR%
call %TO_JAVA% -uri wsdl/%WSDL_FILE% -S generated -o axis -ss -sd -ssi --noWSDL
call %TO_JAVA% -uri wsdl/%WSDL_FILE% -S generated -o axis
This is my WS implementation
package com.at.iscrizio.ws.services;
public class SalutareServiceEx implements SalutareServiceSkeletonInterface {
#Override
public SayciaoResponse sayciao(Sayciao sayciao) {
SayciaoResponse resp = new SayciaoResponse();
resp.set_return("Ciao");
return resp;
}
}
this is my service.xml (a little bit different from the one that the standard axis build.xml generated, just to change the ServiceClass):
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file was auto-generated from WSDL -->
<!-- by the Apache Axis2 version: 1.6.1 Built on : Aug 31, 2011 (12:22:40 CEST) -->
<serviceGroup>
<service name="SalutareServiceEx">
<messageReceivers>
<messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="com.at.iscrizio.ws.services.SalutareServiceMessageReceiverInOut"/>
</messageReceivers>
<parameter name="ServiceClass">com.at.iscrizio.ws.services.SalutareServiceEx</parameter>
<parameter name="useOriginalwsdl">true</parameter>
<parameter name="modifyUserWSDLPortAddress">true</parameter>
<operation name="sayciao" mep="http://www.w3.org/ns/wsdl/in-out" namespace="http://services.ws.iscrizio.at.com">
<actionMapping>urn:sayciao</actionMapping>
<outputActionMapping>urn:sayciaoResponse</outputActionMapping>
</operation>
</service>
</serviceGroup>
Inside server-config.wsdd, I have:
<handler name="Trace" type="java:com.at.iscrizio.ws.handler.TraceHandler"/>
<service name="SalutareServiceEx" provider="java:RPC">
<requestFlow>
<handler type="Trace"/>
</requestFlow>
<parameter name="allowedMethods" value="sayciao"/>
<parameter name="scope" value="Request"/>
<parameter name="className" value="com.at.iscrizio.ws.services.SalutareServiceEx"/>
</service>
I'm able to see the page http://localhost:9090/Iscrizio/services/SalutareServiceEx?wsdl
We're almost at the end...With this piece of code, i'm using the stub to call the ws:
SalutareServiceStub stub = new SalutareServiceStub();
SalutareServiceStub.Sayciao param = new SalutareServiceStub.Sayciao();
param.setName("Antonio");
SalutareServiceStub.SayciaoResponse resp = stub.sayciao(param);
System.out.println(resp);
the request pass through my handler (the one defined inside the wsdd), I can see using the remote debug.
Using TCPMon, i saw my request:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns1:sayciao xmlns:ns1="http://services.ws.iscrizio.at.com">
<ns1:name>Antonio</ns1:name>
</ns1:sayciao>
</soapenv:Body>
</soapenv:Envelope>
and the ws response:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance">
<soapenv:Body>
<soapenv:Fault>
<soapenv:Code>
<soapenv:Value>soapenv:Sender</soapenv:Value>
<soapenv:Subcode xmlns:ns1="http://www.w3.org/2003/05/soap-rpc">
<soapenv:Value>ns1:BadArguments</soapenv:Value>
</soapenv:Subcode>
</soapenv:Code>
<soapenv:Reason>
<soapenv:Text xml:lang="en">string</soapenv:Text>
</soapenv:Reason>
<soapenv:Detail>
<ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">anto-note</ns2:hostname>
</soapenv:Detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
This is the stack trace:
Exception in thread "main" org.apache.axis2.AxisFault: string
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at com.at.iscrizio.ws.services.SalutareServiceStub.sayciao(SalutareServiceStub.java:185)
at com.at.iscrizio.ws.client.TestClient.main(TestClient.java:25)
Where is the problem? Excuse me for the huge post, thanks to all
At least you know that it's the server end that had the problem. The req that soapui is generating is different from your orig req? Sounds strange but soapui is usually right. Personally I would debug the server end and try to figure out where it's going wrong eg set some exception breakpoints