I have a webservice from a partner that am developing against in C#. I have browsed it on SOAPUI and this is the request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ser="http://service.bank.pmt.tpa" xmlns:xsd="http://bean.bank.pmt.tpa/xsd">
<soapenv:Header/>
<soapenv:Body>
<ser:processPaymentNotificationReport>
<!--Zero or more repetitions:-->
<ser:pmtNotifyReport>
<!--Optional:-->
<xsd:amountPaid>?</xsd:amountPaid>
<!--Optional:-->
<xsd:bankBranchCode>?</xsd:bankBranchCode>
<!--Optional:-->
<xsd:bankTransNo>?</xsd:bankTransNo>
<!--Optional:-->
<xsd:datePaid>?</xsd:datePaid>
<!--Optional:-->
<xsd:paymentRegTransNo>?</xsd:paymentRegTransNo>
<!--Optional:-->
<xsd:status>?</xsd:status>
<!--Optional:-->
<xsd:taxPayerName>?</xsd:taxPayerName>
<!--Optional:-->
<xsd:tin>?</xsd:tin>
<!--Optional:-->
<xsd:transactionId>?</xsd:transactionId>
</ser:pmtNotifyReport>
</ser:processPaymentNotificationReport>
when i input the parameters and browse, this is the response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<faultcode>wsse:InvalidSecurity</faultcode>
<faultstring>Missing wsse:Security header in request</faultstring>
<detail/>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
I have reconstructed the request xml in my code then send the xml to the partner by invoking their url. Now i find out that i cannot hit their webservice until i implement the security certificate. I have no idea how i can import that security certificate and use it in my code, need some help pease.
Related
I need to remove the <tem:testApi> tag from the provided code, I have tried OperationContract, MessageContract, DataContract, and XmlSerilizer Contract but none of them are working.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:testApi> <--(I want to remove this tag )
<!--Optional:-->
<tem:Request>
<!--Optional:-->
<tem:Header>
I am now implementing AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext) method of IDispatchMessageInspector interface to intercet the WCF SOAP message.
System.ServiceModel.Channels.Message request as below
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header>
<To soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:8993/TLS.svc/soap</To>
<Action soapenv:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/TLS/GetMerchant</Action>
</soapenv:Header>
<soapenv:Body>
<tem:GetMerchant>
<tem:item1>value1</tem:item1>
<tem:item2>value2</tem:item2>
</tem:GetMerchant>
</soapenv:Body>
</soapenv:Envelope>
I would like to read and alter the value of <tem:item1></tem:item1> <tem:item2></tem:item2> and update back to System.ServiceModel.Channels.Message request without damaging other message original properties
<soapenv:Envelope ... >
<soapenv:Header>
<To soapenv:mustUnderstand="1" ... </To>
<Action soapenv:mustUnderstand="1" ... </Action>
</soapenv:Header>
<soapenv:Body>
<tem:GetMerchant>
<tem:item1>Updatedvalue1</tem:item1>
<tem:item2>Updatedvalue2</tem:item2>
</tem:GetMerchant>
</soapenv:Body>
</soapenv:Envelope>
This post describes the way you can handle it at Dispatcher level, which will allow you to intercept all incoming messages. You just need to understand and read it carefully.
https://weblogs.asp.net/paolopia/writing-a-wcf-message-inspector
I'm working on a .Net client application that will consume a non .Net web service via SOAP standard, to calculate and post Sales Tax information for items. There is no .asmx. The web service is authored and maintained by a different group. They provided a WSDL url and said all the XSD schemas I need are present in it. The problem is, it is nested and daisy chained using xsd:import tags, a few levels deep.
I have the web service added to my Visual Studio 2012 Windows Forms project by "Add Service Reference". Calling this web service was not straight forward as it had some additional security requirements.
The web service has 3 operations - HeartBeat, Calculate, Post.
With my very limited knowledge of WCF and some help from another expert, I was able to call the heartbeat function successfully; this was the easiest because it takes no parameters.
My struggle is, how to structure the input to call the other two functions - Calculate and Post ? They both take a strongly typed object as input. How do I construct such a strongly typed object when this application(.Net) will be called by another one elsewhere?
At the moment, as an experiment, I'm constructing an object based on the proxy classes VS2012 created for the service reference, initializing and populating them with some values manually. Should I use XSD.exe to generate classes for the schemas from WSDL and populate them with the input by deserializing?
Below is the SOAP call to the calculate function. This works when invoked from SoapUI.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:v1="http://MyCompany.com/svc/Finance/SalesTax/v1/">
<soap:Header/>
<soap:Body>
<v1:calculate>
<CalculateRequest>
<Context>
<!--Optional:-->
<SendingApplication>SoapUI</SendingApplication>
<!--Optional:-->
<UserId>SoapUI</UserId>
<!--Zero or more repetitions:-->
<LocaleCode>en</LocaleCode>
<!--Optional:-->
<ApplicationName>SoapUI</ApplicationName>
</Context>
<TaxRequestor>
<Name>Person X</Name>
<!--Optional:-->
<!--Optional:-->
<AdministrativeAddress>
<Line1>888 River Dr</Line1>
<City>Queens</City>
<County>Queens County</County>
<State>NY</State>
<PostalCode>11001</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</AdministrativeAddress>
<CompanyNumber>1</CompanyNumber>
</TaxRequestor>
<Transaction>
<!--1 or more repetitions:-->
<LineItem>
<LineNumber>1</LineNumber>
<!--Optional:-->
<Item>
<!--Optional:-->
<Identifier>10134</Identifier>
<!--Zero or more repetitions:-->
<Name LocaleCode="en-US">Product X</Name>
<!--Optional:-->
<TaxCode>9876</TaxCode>
<Department>
<!--Optional:-->
<Code>99</Code>
<!--Zero or more repetitions:-->
<Name LocaleCode="en-US">?</Name>
</Department>
</Item>
<!--Optional:-->
<Quantity>10</Quantity>
<!--Optional:-->
<UnitPrice>
<Amount>1000</Amount>
</UnitPrice>
<ShipFromAddress>
<Line1>888 River Dr</Line1>
<City>Queens</City>
<County>Queens County</County>
<State>NY</State>
<PostalCode>11001</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipFromAddress>
<ShipToAddress>
<Line1>1041 New York Rd</Line1>
<City>Newark</City>
<County>Essex</County>
<State>NJ</State>
<PostalCode>07054</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipToAddress>
<!--Zero or more repetitions:-->
<LineItemIdentifier>1</LineItemIdentifier>
</LineItem>
<LineItem>
<LineNumber>1</LineNumber>
<!--Optional:-->
<Item>
<!--Optional:-->
<Identifier>98765</Identifier>
<!--Zero or more repetitions:-->
<Name LocaleCode="en-US">Product X</Name>
<!--Optional:-->
<TaxCode>Some Tax Code</TaxCode>
<Department>
<!--Optional:-->
<Code>99</Code>
</Department>
</Item>
<!--Optional:-->
<Quantity>10</Quantity>
<!--Optional:-->
<UnitPrice>
<Amount>1000</Amount>
</UnitPrice>
<ShipFromAddress>
<Line1>888 River Dr</Line1>
<City>Queens</City>
<County>Queens County</County>
<State>NY</State>
<PostalCode>11001</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipFromAddress>
<ShipToAddress>
<Line1>1008 3rd St</Line1>
<City>Lewisville</City>
<County>Denton</County>
<State>TX</State>
<PostalCode>75010</PostalCode>
<CountryISO3Char>USA</CountryISO3Char>
</ShipToAddress>
<!--Zero or more repetitions:-->
<LineItemIdentifier>1</LineItemIdentifier>
</LineItem>
</Transaction>
</CalculateRequest>
</v1:calculate>
</soap:Body>
</soap:Envelope>
Please help with your advice and recommendations. Thank you. Using VS2012, .Net 4.5, C#
I have below Soap response XML string
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header />
<soapenv:Body>
<qu:quotationResponse xmlns:qu="http://Reliance_RENEWAL_Quotation/IRenewal_Quotation">
<response><?xml version="1.0" encoding="UTF-8"?>
<RENEWAL-QUOTATION-RESPONSE>
<MESSAGE-DATA>
<ContractType>XYZ </ContractType>
<PremiumAmount>10000</PremiumAmount>
<PremiumSuspense>0.0</PremiumSuspense>
<NetAmmount>10000.0</NetAmmount>
<ContractPremiumStatus>Surrender </ContractPremiumStatus>
<ContractOwnerClientNumber>0501234</ContractOwnerClientNumber>
<OwnerName>SUDZ</OwnerName>
<LifeAssuredClientNumber>12312312</LifeAssuredClientNumber>
<LifeAssuredName>SUDZ </LifeAssuredName>
<PaidTodate>20110731</PaidTodate>
<ReinstatementFee>0.0</ReinstatementFee>
<ContractNumber>1122112211</ContractNumber>
</MESSAGE-DATA>
<ERROR-DETAILS>
<ErrorCode>No Errors</ErrorCode>
<ErrorDesc></ErrorDesc>
</ERROR-DETAILS>
</RENEWAL-QUOTATION-RESPONSE>
</response>
</qu:quotationResponse>
</soapenv:Body>
</soapenv:Envelope>
I need the value of ContractType, NetAmount etc
I tried but not able to parse.
What is best the way to parse above xml.
Please help.
I have a problem with some calls to a web service:
When I create the SoapEnveloper I put this on the wire
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:GetUserIDByName>
<tem:sUser>sample</tem:sUser>
<tem:oParam>
<tem:CountryURL>US</tem:CountryURL>
<tem:noCache>false</tem:noCache>
</tem:oParam>
</tem:GetUserIDByName>
</soapenv:Body>
</soapenv:Envelope>
But the response comes as:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:16092960528611E1BFADB7181697B03B</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
<wsa:ReferenceParameters>
<instra:tracking.ecid xmlns:instra="http://xmlns.oracle.com/sca/tracking/1.0">0000JLUJsMq0VsSqyCBh6G1FCdSn000GYf</instra:tracking.ecid>
</wsa:ReferenceParameters>
</wsa:ReplyTo>
</env:Header>
<env:Body>
<GetUserIDByNameResponse xmlns="http://tempuri.org/">
<Error>
<ErrorCode>0</ErrorCode>
<ErrorMessage>''</ErrorMessage>
</Error>
<ReturnValue>0</ReturnValue>
<GetUserIDByNameResult>9815</GetUserIDByNameResult>
</GetUserIDByNameResponse>
</env:Body>
</env:Envelope>
Now the autogenerated proxy classes for this service call has the following attribute:
[SoapDocumentMethodAttribute("http://tempuri.org//GetUserNameById",
RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
corresponding to the default namespace.
The problem seems that the de-serialization process does not seem to understand the response.
Any idea on how to fix this?