EWS request fails because not Internet - soap

I am calling EWS service on internal network which has not access to Internet.
I can open EWS url with browser and verify that it is up an running.
But when I try to send the SOAP request.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2007_SP1" />
</soap:Header>
<soap:Body>
<m:GetFolder>
<m:FolderShape>
<t:BaseShape>IdOnly</t:BaseShape>
</m:FolderShape>
<m:FolderIds>
<t:DistinguishedFolderId Id="calendar" />
</m:FolderIds>
</m:GetFolder>
</soap:Body>
</soap:Envelope>
It fails with error ENOTFOUD. I am assuming that it can not connect to given address in the SOAP xml for schema definitions.
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
How to deal with this when there is no internet connection.
I am sending request from meteor.js app using lather.js library.

The stuff that looks like URL:s, prefixed with xmlns, are just name spaces and shall not be called. A bit like namespaces in a java program (for example namespace com.sun.something) is not an url you can call.
You should just do a http POST and send the entire xml file to the soap server, which can be an internal ip number that is not on the internet.

Related

Get folder List for a particular email using GetFolder operation from Exchange Web Service using SOAP Message

I am using SOAPUI for my test. We have a service account linked to multiple inboxes. I am using GetFolder Operation of Exchange Web Services, specifying the request Header with Email ID. It seems like EWS is ignoring the provided email ID into the Soap header and only returning default inbox (I am supplying shared inbox in the header, connected to service account that is being used in authentication).
Kindly help to identify of my request is correct or Do i need to specify some flag to make sure my share inbox is accessible from my request?
Here is the sample request.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
<soap:Header>
<t:ConnectingSID>
<!--You have a CHOICE of the next 4 items at this level-->
<t:PrincipalName>mysharedinbox#mydomain.com</t:PrincipalName>
<t:PrimarySmtpAddress>mysharedinbox#mydomain.com</t:PrimarySmtpAddress>
<t:SmtpAddress>mysharedinbox#mydomain.com</t:SmtpAddress>
</t:ConnectingSID>
</soap:Header>
<soap:Body>
<FindFolder Traversal="Shallow" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<FolderShape>
<t:BaseShape>Default</t:BaseShape>
</FolderShape>
<ParentFolderIds>
<t:DistinguishedFolderId Id="msgfolderroot"/>
</ParentFolderIds>
</FindFolder>
</soap:Body>
</soap:Envelope>
If the service account has access to the Mailbox in question then you need to use the Mailbox child node of DistinguishedFolderId to specify the Mailbox you want to access eg
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<t:RequestServerVersion Version="Exchange2013" />
</soap:Header>
<soap:Body>
<m:GetFolder>
<m:FolderShape>
<t:BaseShape>AllProperties</t:BaseShape>
</m:FolderShape>
<m:FolderIds>
<t:DistinguishedFolderId Id="inbox"><t:Mailbox><t:EmailAddress>mailbox#domain.com</t:EmailAddress></t:Mailbox></t:DistinguishedFolderId>
</m:FolderIds>
</m:GetFolder>
</soap:Body>
</soap:Envelope>
The only time you would use ConnectingSID is when your using EWS impersonation (where you have those rights) and your impersonation header should look like
<soap:Header>
<t:ExchangeImpersonation>
<t:ConnectingSID>
<t:PrimarySmtpAddress>alisa#contoso.com</t:PrimarySmtpAddress>
</t:ConnectingSID>
</t:ExchangeImpersonation>
</soap:Header>

SOAP Object reference not set to an instance of an object

I'm attempting to run a search for a ticket on ChangeGear 5.0. Their API utilizes SOAP requests, and when I run a request to search I get the error "Object reference not set to an instance of an object". I've looked through existing topics concerning the same issue (there are a lot of them), and I've tried all of them with no luck. Non-required parameters are included as empty tags instead of omitted entirely, I've tried capitalizing the names of the parameters, and I've made sure the request is formatted appropriately according to the WSDL.
The provided ChangeGear 5.0 documentation specifies to structure requests like so:
POST /cgweb/cgwebservices/cgwebservices.asmx HTTP/1.1
Host: ...
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Search xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<sessionId>string</sessionId>
<entityType>string</entityType>
<criteria>string</criteria>
<retrieveRelated>boolean</retrieveRelated>
<entityTemplate>string</entityTemplate>
</Search>
</soap12:Body>
</soap12:Envelope>
This is the request I'm POSTing with the specified headers:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Search xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<sessionId></sessionId>
<entityType></entityType>
<criteria></criteria>
<retrieveRelated>true</retrieveRelated>
<entityTemplate></entityTemplate>
</Search>
</soap12:Body>
</soap12:Envelope>
The only parameter I've set is retrieveRelated because as specified by the WSDL it is the only required parameter, but I've also tried setting all the string parameters to arbitrary non-null values and received the same result. I'm sure the API is functional because when I use the login operation it returns successfully:
POST /cgweb/cgwebservices/cgwebservices.asmx HTTP/1.1
Host: ...
Content-Type: application/soap+xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<Login xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<userName>...</userName>
<password>...</password>
</Login>
</soap12:Body>
</soap12:Envelope>
Result:
200 OK
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LoginResponse xmlns="http://www.sunviewsoftware.com/CGWebServices/">
<LoginResult>...</LoginResult>
</LoginResponse>
</soap:Body>
</soap:Envelope>
I am using the same session I used for the login operation. Is there anything else I can try besides including empty tags for omitted parameters or capitalizing their names? The full error is:
500 Internal Server Error
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">Object reference not set to an instance of an object.</soap:Text>
</soap:Reason>
<soap:Node>.../cgweb/cgwebservices/cgwebservices.asmx</soap:Node>
<detail>
<Error xmlns=".../cgweb/cgwebservices/cgwebservices.asmx">
<ErrorNumber>0</ErrorNumber>
<ErrorMessage/>
<ErrorCode>L_REJECT_CHANGES_FAILED</ErrorCode>
</Error>
<Error xmlns=".../cgweb/cgwebservices/cgwebservices.asmx">
<ErrorNumber>0</ErrorNumber>
<ErrorMessage>Object reference not set to an instance of an object.</ErrorMessage>
<ErrorCode>Object reference not set to an instance of an object.</ErrorCode>
</Error>
<Error xmlns=".../cgweb/cgwebservices/cgwebservices.asmx">
<ErrorNumber>0</ErrorNumber>
<ErrorMessage>Object reference not set to an instance of an object.</ErrorMessage>
<ErrorCode/>
</Error>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
The problem was that the server wasn't adhering to the WSDL. The entityTemplate parameter was required, and without it the server returns the "Object reference not set to an instance of an object" error. When I initially tested the parameters with dummy values, out of coincidence I had accidentally forgot to set this one -- the only one that strayed from the WSDL specification.

How to retrieve SOAP response header in a SOAPFaultException in Apache CXF

I have a trouble in Apache CXF where some code throws SOAPFaultException.
My original SOAP response is as following :
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope ...>
<soap:Header>
<awsse:Session TransactionStatusCode="InSeries">
<awsse:SessionId>012GBF5W3H</awsse:SessionId>
<awsse:SequenceNumber>1</awsse:SequenceNumber>
<awsse:SecurityToken>3CGFFDO499VDB7WTRT37R6HPV</awsse:SecurityToken>
</awsse:Session>
</soap:Header>
<soap:Body>
<soap:Fault xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode>soap:Client</faultcode>
<faultstring>SOME_FAULT_STRING</faultstring>
<faultactor>SOME_FAULT_FACTOR</faultactor>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I receive later a SOAPFaultException with information contains only soap:Body/soap:Fault. However, I need information from soap:Header section for further processing.
How can I pass these Header information to SOAPFaultException?

Request to web services failed using php, succeeded from windows client

I have written a web service using asp.net 2.0 and a simple method "HelloWorld" to test it. Here is the soap envelope which the server receives:
<?xml version="1.0" encoding="utf-8"?>
<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:Header>
<SoapAuthHeader xmlns="http://myservice.anywhere.net/">
<UserName>MyUser</UserName>
<Password>MyPassword</Password>
</SoapAuthHeader>
</soap:Header>
<soap:Body>
<HelloWorld xmlns="http://myservice.anywhere.net/">
<request>
<?xml version="1.0" encoding="utf-16"?>
<HelloWorld />
</request>
</HelloWorld>
</soap:Body>
</soap:Envelope>
My Problem is: If I send the request from a Windows Client with embedded wsdl it succeeds. If I send the request from php (or SoapUI) the request fails - the server gets no "request" string, means no content for the body.
The server receives in both cases the same soap envelope above (logged it with a trace extension).
Thanks for any help.
Harald
P.S. No matter if I use embedded XML or embedded string for the request.
Using the asmx trace I have found the problem at least with SoapUI. The requested requirement category was "text/xml" and it got "application/soap+xml". I have disabled "Soap action" and the call succeeds.

Auth in sharepoint wsdl

I used soapUI tool for fetch soap request from my dummy wsdl server
<?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>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
and take response. But when I try to take request from my real server I cant auth. In soap envelope I added header
<soap:Header>
<AUTHHEADER>
<USERNAME>Administrator</USERNAME>
<PASSWORD>Password</PASSWORD>
</AUTHHEADER>
</soap:Header>
but something wrong. Login and pass is right, I checked.
UPD1
I send query 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:AUTHHEADER>
<soap:USERNAME>Administrator</soap:USERNAME>
<soap:PASSWORD>Password</soap:PASSWORD>
</soap:AUTHHEADER>
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
and I have
<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>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server was unable to read request. ---> Request format is invalid: Missing required soap:Body element.</faultstring>
<detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
from real server.
Try to change your query 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:Header xmlns:ns0="http://schemas.microsoft.com/sharepoint/soap/">
<ns0:AUTHHEADER>
<ns0:USERNAME>Administrator</ns0:USERNAME>
<ns0:PASSWORD>Password</ns0:PASSWORD>
</ns0:AUTHHEADER>
</soap:Header>
<soap:Body>
<GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" />
</soap:Body>
</soap:Envelope>
EDIT1: repair example to add another ns to authheader. Be honest: I don't know, if there is defined an authheader elements in ns of http://schemas.microsoft.com/sharepoint/soap, but I pretend it, because it can be different for every WSDL interface. I know, that there is WSSE standard, but it is coded in XML request differently.