trying to translate from one asmx web service to svc web service. same code, but got the following difference in responce
when using asmx:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://www.MyKidsSpending.com/">-2202.68</string>
when using svc:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">-2202.68</string>
where did the first line go?
Here is the fist couple of lines of the function that I am testing in the svc service....
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Xml)]
public string Balance(string Uid)
{
WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
I was suggested that the response was html, that is why it doesn't have
<?xml version="1.0" encoding="utf-8"?>
now I change text/html to text/xml, why doesn't still match? Suggestions? Thanks
Related
How to verify if my Soap request consists of an particular element in header and body using JSON and standalone WireMock.
I should get response1 if my request contain <a:Id>1876</a:Id> in the header else i should get response2
similarly i need to check in body also.
Below is my request XML
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:a="http://abc.example.com/a"
xmlns:b="http://abc.example.com/b"
xmlns:c="http://abc.example.com/c"
<soapenv:Header>
<a:abcHeaders>
<a:Id>1876</a:Id>
<a:Xid>12</a:Xid>
</a:abcHeaders>
</soapenv:Header>
<soapenv:Body>
<b:abcOpern>
<b:xyz>
<c:pqr>12</c:pqr>
</b:xyz>
</b:abcOpern>
</soapenv:Body>
</soapenv:Envelope>
In WireMock.Net you can use XPath matching. For some details see here.
I'm trying to get even the simplest WFS HTTP_POST request to work, against a GeoServer WFS endpoint.
This HTTP_GET request works, and returns what I expect (newlines inserted for clarity):
http://mygeoserver.com/geoserver/ows?
service=wfs&
version=2.0.0&
request=getfeature&
count=3&
typenames=mynamespace:myfeaturetype&
cql_filter=dccode=%27XYZ%27
I'd expect this HTTP_POST request:
http://mygeoserver.com/geoserver/ows
with this request body:
<GetFeature
version="2.0.0"
service="WFS"
count="3"
xmlns="http://www.opengis.net/wfs/2.0"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs/2.0
http://schemas.opengis.net/wfs/2.0/wfs.xsd"
>
<Query
typeNames="mynamespace:myfeaturetype"
>
<Filter
xmlns="http://www.opengis.net/fes/2.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gsml="http://xmlns.geosciml.org/GeoSciML-Core/3.2" >
<PropertyIsEqualTo>
<ValueReference>dccode</ValueReference>
<Literal>XYZ</Literal>
</PropertyIsEqualTo>
</Filter>
</Query>
</GetFeature>
to return the same.
Instead I get an error:
cvc-datatype-valid.1.2.3: 'mynamespace:myfeaturetype' is not a valid value of union type 'TypeNamesType'.
cvc-attribute.3: The value 'mynamespace:myfeaturetype' of attribute 'typeNames' on element 'Query' is not valid with respect to its type, 'TypeNamesListType'.
What's throwing me for a loop is that the very same value that works for the typeNames parameter in the HTTP_GET throws an error in the HTTP_POST.
The problem seems to be that I need to specify a namespace definition in the XML for "mynamespace".
<Query
typeNames="mynamespace:myfeaturetype"
xmlns:mynamespace="http://????"
>
I'm assuming that this is available, somewhere within my GeoServer installation. But where?
It will be whatever you set as the URI of the workspace mynamespace. You can look it using a describeFeature request. So for example:
curl http://localhost:8080/geoserver/wfs\?service=wfs\&version=1.1.0\&request=DescribeFeatureType\&typeName=topp:states
gives:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:gml="http://www.opengis.net/gml"
xmlns:topp="http://www.openplans.org/topp"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://www.openplans.org/topp">
<xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://localhost:8080/geoserver/schemas/gml/3.1.1/base/gml.xsd"/>
<xsd:complexType name="statesType">
<xsd:complexContent>
[....]
So, we've SOAP server configured at backend and sending POST requests to SOAP endpoint with JSON body and get error like:
Any solutions or causes please?
<?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">System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Web.Services.Protocols.SoapServerProtocol.SoapEnvelopeReader.MoveToContent()
at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement()
at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
--- End of inner exception stack trace ---</soap:Text>
</soap:Reason>
<soap:Detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
I have transformation in dataweave.
I am getting input from the Mysql database. Input payload type is List- Map. My dataweave editer has below code.
%dw 1.0
%namespace ns1 urn:abc:api:Components
%output application/xml
---
ns1#"ItemRequest":{
ns1#"Requester":
ns1#ac: payload.time_max,
ns1#"ErrorLanguage": "en_US",
ns1#"WarningLevel": "High"
}
My output is
<?xml version='1.0' encoding='UTF-8'?>
<ns1:ItemRequest xmlns:ns1="urn:abc:api:Components">
<ns1:Requester>
<ns1:ac>
<time_max>1</time_max>
</ns1:ac>
</ns1:Requester>
<ns1:ErrorLanguage>en_US</ns1:ErrorLanguage>
<ns1:WarningLevel>High</ns1:WarningLevel>
</ns1:AddItemRequest>
I am not sure why i am getting tag created under'ac' element in my output with 'time_max'. The 'Time_max' is the column name in MySQL table. But i dont want to add the column in the output xml. How can we avoid this tag creation ?
Expected output is
<?xml version='1.0' encoding='UTF-8'?>
<ns1:ItemRequest xmlns:ns1="urn:abc:api:Components">
<ns1:Requester>
<ns1:ac>1</ns1:ac>
</ns1:Requester>
<ns1:ErrorLanguage>en_US</ns1:ErrorLanguage>
<ns1:WarningLevel>High</ns1:WarningLevel>
</ns1:AddItemRequest>
I have resolved the issue by typing below code.
%dw 1.0
%namespace ns1 urn:abc:api:Components
%output application/xml
---
ns1#"ItemRequest":{
ns1#"Requester":
ns1#ac: payload[0].time_max,
ns1#"ErrorLanguage": "en_US",
ns1#"WarningLevel": "High"
}
The below line of snippet is did magic. I have included array index values.
ns1#ac: payload[0].time_max
I have a Web Service that i have created using C# and Visual Studio 2010. The definition is below.
[WebService(Namespace = "http://targetrocksoftware.org")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class GetAssessmentResults : System.Web.Services.WebService
{
SchoolTestManagerDBContainer SchoolDB = new SchoolTestManagerDBContainer();
[WebMethod]
public XmlDocument GetAssessment(int assessmentid)
{
int intid = 88;
Assessment a = SchoolDB.Assessments.SingleOrDefault(m=>m.Id == (int) intid);
if (a != null)
{
MemoryStream ms = new MemoryStream();
Test t = Test.GetTestStructure(a);
t.SerializeTest(ms);
ms.Seek(0, SeekOrigin.Begin); //reset read pointer
XmlDocument xd = new XmlDocument();
xd.Load(ms);
return xd;
}
else
return null;
}
}
it is very simple as you can see and it takes one parameter an integer which is the unique id of a table. No issues you would think. Everthing works except that when i call the web service from SSRS (either in local mode via ReportBuilder 2.0) or directly from the SSRS server, the parameter assessmentid is always 0.
The SSRS report calls the web service using the following query parameter in a dataset.
<Query xmlns="http://targetrocksoftware.org">
<ElementPath IgnoreNamespaces="True">
GetAssessmentResponse/GetAssessmentResult/Test
{
NumQuestions(integer),
nAnswered(integer),
Highest(float),
Lowest(float),
Median(float),
Mean(float),
Correct(integer),
Incorrect(integer),
KR20(float),
StandardDeviation(float),
Variance(float)
}
</ElementPath>
<SoapAction>http://targetrocksoftware.org/GetAssessment</SoapAction>
<Method Namespace="http://targetrocksoftware.org" Name="GetAssessmet">
<Parameters>
<Parameter Name="assessmentid">
<DefaultValue>88</DefaultValue>
</Parameter>
</Parameters>
</Method>
</Query>
Everyting seems to work except the assessmentid parameter is always 0. If I hard code an assessmentid that i know is in the db (in this case 88) the web service returns the correct Xml Document and the report renders perfectly.
But for the life of me i cannot get SSRS to pass the parameter correctly. I have used fiddler2 to look at the request which is copied below
POSThttp://192.168.2.10/WebServices/GetAssessmentResults.asmxHTTP/1.1
SOAPAction:http://targetrocksoftware.org/GetAssessment`
Content-Type: text/xml
Host: 192.168.2.10
Content-Length: 280
Expect: 100-continue
Connection: Keep-Alive
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetAssessmet xmlns="http://targetrocksoftware.org">
<assessmentid>88</assessmentid>
</GetAssessmet>
</soap:Body>
</soap:Envelope>
`
If i use a WebService Test Tool like soapUI to send a request to the service it works (e.g. assessmentid is sest to the value passed, 88). The only thing i can see that is different is that on the request that is sent from soapUI the parameter that is passed has a namespace qualifier. Cany anyone help me please. A netmon trace is included below, that shows the difference between the two requests. My basic question is how do you get ssrs to work (e.g. include the namepace in each part of the soap request (at least that is what i think is wrong:))
- Soap: xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/"
- Envelope: <soapenv:Envelope>
+ STag: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/">
+ Header: <soapenv:Header>
- Body: <soapenv:Body>
+ STag: <soapenv:Body>
- Node: XmlElement:<tar:GetAssessment>
+ STag: <tar:GetAssessment>
- Element: XmlElement:<tar:assessmentid> - 88
+ STag: <tar:assessmentid>
Content: 88
+ ETag: </tar:assessmentid>
+ ETag: </tar:GetAssessment>
+ ETag: </soapenv:Body>
+ ETag: </soapenv:Envelope>- Soap: xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/"
- Envelope: <soapenv:Envelope>
+ STag: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tar="http://targetrocksoftware.org/">
+ Header: <soapenv:Header>
- Body: <soapenv:Body>
+ STag: <soapenv:Body>
- Node: XmlElement:<tar:GetAssessment>
+ STag: <tar:GetAssessment>
- Element: XmlElement:<tar:assessmentid> - 88
+ STag: <tar:assessmentid>
Content: 88
+ ETag: </tar:assessmentid>
+ ETag: </tar:GetAssessment>
+ ETag: </soapenv:Body>
+ ETag: </soapenv:Envelope>
Kevin
If anyone is interested i have solved this issue. Not in a good way, but it is solved. The solution was to start fresh and recreate a new webservice with the exact same functionality. The only difference is that now i have left the service namespace as the default http://tempuri.org. I am not sure why it fixed the issue but it did. If anyone can shed some light on it that would be great
Kevin