Hi I am new at WCF Soap services, I need to connect to a webserver use Xml-Rpc. First I tried to connect and got an error about "xml-rpc encoded" then I added Microsoft.Samples.XmlRpc to project. I can connect to the service but when I try to send Soap message I am getting :
<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:hdr="urn:PASAHeader" xmlns:ns3="urn:PASAMnfGetFlowVehInfo_v2" xmlns:ns1="urn:PASAMnfGetFlowVehInfo" xmlns:ns2="urn:PASAMnfUpdatedFromSupplier" xmlns:ex="urn:PASAexploitationWS">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" id="_0">
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:VersionMismatch</faultcode>
<faultstring>SOAP version mismatch or invalid SOAP message</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I am using that code to convert to xml-rpc
ChannelFactory<ServiceReference2.MnfGetFlowVehInfoPortTypeChannel> typeChannel = new ChannelFactory<ServiceReference2.MnfGetFlowVehInfoPortTypeChannel>(new WebHttpBinding(WebHttpSecurityMode.None), new EndpointAddress(uriAdress));
typeChannel.Endpoint.EndpointBehaviors.Add(new XmlRpcEndpointBehavior());
I tried to change the version using messageVersion in library but I couldn't handle it.Thanks
Related
I am writing a SoapCore web service in .NET Core 5.0 and I have successfully been able to execute the request via SOAPUI and get back a valid response. The only thing I don't like is that it puts unwanted prefixes in the repose message. for example in this response:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Body>
<getMeterIntervalDataByTimeSliceResponse xmlns="http://tempuri.org/">
<getMeterIntervalDataByTimeSliceResult xmlns:d4p1="http://schemas.datacontract.org/2004/07/MeterDataWebService.Models" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:AccountId>1234567890</d4p1:AccountId>
<d4p1:ID>0</d4p1:ID>
<d4p1:IntervalEndTime>2020-12-22T15:30:57.3705724-05:00</d4p1:IntervalEndTime>
<d4p1:IntervalLengthInSeconds>PT5M</d4p1:IntervalLengthInSeconds>
<d4p1:Load>2345.8010350836185</d4p1:Load>
<d4p1:MeterChannel>1</d4p1:MeterChannel>
<d4p1:TimeZone>UT</d4p1:TimeZone>
<d4p1:UnitOfMeasure>KM</d4p1:UnitOfMeasure>
<d4p1:UtcOffset>0</d4p1:UtcOffset>
</getMeterIntervalDataByTimeSliceResult>
</getMeterIntervalDataByTimeSliceResponse>
</s:Body>
</s:Envelope>
How do I get rid of the "d4p1" prefix?
I figured it out. It was in my Startup.cs class.
app.UseSoapEndpoint("/Service.asmx", new
BasicHttpBindingg(), SoapSerializer.XmlSerializer);
I forgot to add the SoapSerializer.XmlSerializer part
We are integrating a service from a third party. They have recently upgraded their service, and now with the new wsdl, I keep getting "Illegal Request format for Element".
From my investigations the problem seems to be with the xmlns that is added on the main element. If I use SOAPUI and remove the xmlns from the main element, it works, however visual studio adds it automatically in accordance with whats defined in the wsdl.
What is interesting is that with their previous wsdl, the service works with the xmlns included, it is only with the new wsdl that it throws an exception.
In terms of the wsdl, all I know is that they used JD 12 and manually created the wsdl, however upon comparing it, it looks similar to the old one with the name in the xmlns being the only difference.
This is the request visual studio creates:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<extractacccategElement xmlns="http://gna160ws/Management.wsdl/types/">
<xSecurity>
<timekey></timekey>
<authkey></authkey>
<publkey></publkey>
<version>1.x</version>
</xSecurity>
<xRequest1>
<supplierno></supplierno>
</xRequest1>
</extractacccategElement>
</s:Body>
</s:Envelope>
With the "xmlns="http://gna160ws/Management.wsdl/types/"" causing the problem.
Response:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header/>
<env:Body>
<srvc:extractacccategElementResponse xmlns="http://gna160ws/Management" xmlns:srvc="http://gna160ws/Management">
<srvc:result>
<response1Out>
<origin>gna160.extractacccategElement</origin>
<invsql>1200</invsql>
<message>Illegal Request format for extractacccategElement.</message>
</response1Out>
</srvc:result>
</srvc:extractacccategElementResponse>
</env:Body>
</env:Envelope>
When submitting the same request, but without the xmlns, I get a valid response. Example:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<extractacccategElement>
<xSecurity>
<timekey></timekey>
<authkey></authkey>
<publkey></publkey>
<version>1.x</version>
</xSecurity>
<xRequest1>
<supplierno></supplierno>
</xRequest1>
</extractacccategElement>
</s:Body>
</s:Envelope>
Response:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<ns0:extractacccategElementResponse xmlns="http://gna160ws/Management" xmlns:srvc="http://gna160ws/Management">
<ns0:result>
<ns0:acccategOut>
<ns0:invsql>0</ns0:invsql>
<ns0:message>Success</ns0:message>
<ns0:origin>gna160pkg.ExtractAccCateg</ns0:origin>
<ns0:stage>1</ns0:stage>
<ns0:acccategcode>A</ns0:acccategcode>
<ns0:acccategname>AAA</ns0:acccategname>
</ns0:acccategOut>
</ns0:result>
</ns0:extractacccategElementResponse>
</env:Body>
</env:Envelope>
Additionally, if I add a qualifer after the xmlns then it also works??
Example:
xmlns:hello="http://gna160ws/Management.wsdl/types/"
I have been working collaboratively with the developer on their side and we have not yet been able to identify the problem.
If anyone could help or point me in the right direction, it would be greatly appreciated.
Did you update your service reference with the new WSDL?
Alternatively you can try this answer from Rick Strahl: override the following function to add a custom namespace.
protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer)
{
writer.WriteStartElement("soapenv", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
writer.WriteAttributeString("xmlns", "oas", null, "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
writer.WriteAttributeString("xmlns", "v2", null, "http://www.royalmailgroup.com/api/ship/V2");
writer.WriteAttributeString("xmlns", "v1", null, "http://www.royalmailgroup.com/integration/core/V1");
writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
}
Link to his complete article
I've been facing lots of problem with a WebService implementation. I know that this website has some topics related with it, but I've tried the steps I've found and nothing work to me.
I created a .NET WebService that will be called by QAD ERP. I've installed the Web Service on our server that can be accessed by the following address: 187.72.208.85/qadws/QADXmlWS.asmx
The ERP is calling the Web Service sending the XML below:
<?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></soap:Header>
<soap:Body>
<qdoc:Item xmlns:qdoc="http://187.72.208.85/QADWs/QADXmlWs/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<qdoc:file>
<qdoc:operation>A</qdoc:operation>
<qdoc:ptAdded>2015-06-09</qdoc:ptAdded>
<qdoc:ptCdCmmt/>
<qdoc:ptCdRef>DI</qdoc:ptCdRef>
</qdoc:file>
</qdoc:Item>
</soap:Body>
</soap:Envelope>
The web service code is:
[WebService(Namespace = "http://187.72.208.85/QADWs/QADXmlWs/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class QADXmlWs : System.Web.Services.WebService
{
[WebMethod]
public void Item(byte[] file)
{
File.WriteAllBytes(#"c:/ws/Item.xml", file);
}
}
When I call Web Service, it gives me the following error:
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Server did not recognize the value of HTTP SOAPAction: 'http://187.72.208.85/QADWs/QADXmlWs/Item'.</faultstring>
<detail />
</soap:Fault>
I don't have any idea how I can solve this problem.
Could you help me out with this issue?
I've received documentation from a client to use the below SOAP request. I've never worked with SOAP before and I'm using the solution listed in this question: Client to send SOAP request and received response
However, when soapEnvelop.LoadXml is run I get: 'head' is an undeclared prefix. Line 5, position 39.
Here is the SOAP xml I received from my client:
<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>
<head:CustomCredentials>
<head:UserName>Username</head:UserName>
<head:Password>Password</head:Password>
<head:Source>Code</head:Source>
<head:CurrentCulture>en-CA</head:CurrentCulture>
</head:CustomCredentials>
</soap:Header>
<soap:Body>
<WebServiceMethodName xmlns='Web Service Namespace' />
</soap:Body>
</soap:Envelope>
I'm not entierly sure what to do here. From googling I believe that the element head just doesn't exist in the namespace.
I am calling GetRoomLists using Exchange Web Services, we are running Exchange 2010. The below code is being executed through a Console application. The call succeeds, per the XML response of "No Error", but no data is returned. We have several hundred rooms listed when you try to add one through an Outlook Appointment, so not sure why this would happen.
I've tried using both EWS DLL version 1.2 and 2.0, using default credentials or passing in credentials. I noticed after originally posting this that the response header says we are using Exchange 2012 SP2, so I tried updating my code to use that ExchangeVersion enum value, but no change in the result.
I have successfully used EWS on this Exchange server to read mailboxes, but never rooms before.
C#
ExchangeService es = new ExchangeService(ExchangeVersion.Exchange2010);
es.TraceFlags = TraceFlags.EwsResponse | TraceFlags.EwsRequest;
es.TraceEnabled = true;
es.UseDefaultCredentials = true;
es.AutodiscoverUrl("autodiscover#example.com");
//this collection is empty after processing
EmailAddressCollection eac = es.GetRoomLists();
XML Trace From Web Service Request/Response
<Trace Tag="EwsRequest" Tid="9" Time="2013-03-13 20:39:41Z" Version="14.03.0032.000">
<?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="Exchange2010" />
</soap:Header>
<soap:Body>
<m:GetRoomLists />
</soap:Body>
</soap:Envelope>
</Trace>
<Trace Tag="EwsResponse" Tid="9" Time="2013-03-13 20:39:41Z" Version="14.03.0032.000">
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:ServerVersionInfo MajorVersion="14" MinorVersion="2" MajorBuildNumber="328" MinorBuildNumber="9" Version="Exchange2010_SP2" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<GetRoomListsResponse ResponseClass="Success" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
<ResponseCode>NoError</ResponseCode>
<m:RoomLists xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" />
</GetRoomListsResponse>
</s:Body>
</s:Envelope>
</Trace>
MSDN Documentation on GetRoomLists: http://msdn.microsoft.com/en-us/library/dd899416(v=exchg.140).aspx
Well I found the cause/solution. The confusion was in that GetRoomLists does not return a list of rooms, but instead a list of a list of rooms, or a collection of "Room Lists". These are a special type of distribution list that contains a list of rooms.
As outlined here, http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/4ff04c60-48c2-4a69-ab75-2383e73bfde2, you either need to setup room lists or you need to query AD and check the msExchRecipientDisplayType attribute to track down the rooms.
This link shows an example of how to write the LDAP query to return rooms: http://social.msdn.microsoft.com/Forums/en-US/exchangesvrdevelopment/thread/e2d10953-a8f9-459c-8a0e-f10c2e568b26
Code I put together for finding rooms:
private List<string> GetConfRooms(string filter)
{
List<string> sRooms = new List<string>();
DirectoryEntry deDomain = System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().GetDirectoryEntry();
DirectorySearcher dsRooms = new DirectorySearcher(deDomain);
dsRooms.Filter = string.Format("(&(&(&(mailNickname={0}*)(objectcategory=person)(objectclass=user)(msExchRecipientDisplayType=7))))", filter);
dsRooms.PropertiesToLoad.Add("sn");
dsRooms.PropertiesToLoad.Add("mail");
foreach (SearchResult sr in dsRooms.FindAll())
{
sRooms.Add(sr.Properties["mail"][0].ToString());
}
return sRooms;
}