I need to use .Net wcf web service. but I can't success it. I saw error and it is written:
org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null#1:0 in java.io.InputStreamReader#46029560)
Can you help me how I use this web service?
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" name="Service" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<xs:import namespace="http://schemas.datacontract.org/2004/07/"/>
<xs:import namespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
<xs:element name="GetTreatmentValues">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="tID" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">...</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/">...</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/Arrays" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/Arrays">...</xs:schema>
</wsdl:types>
<wsdl:message name="IService_GetTreatmentValues_InputMessage">
<wsdl:part name="parameters" element="tns:GetTreatmentValues"/>
</wsdl:message>
<wsdl:message name="IService_GetTreatmentValues_OutputMessage">
<wsdl:part name="parameters" element="tns:GetTreatmentValuesResponse"/>
</wsdl:message>
<wsdl:portType name="IService">
<wsdl:operation name="GetTreatmentValues">
<wsdl:input wsaw:Action="http://tempuri.org/IService/GetTreatmentValues" message="tns:IService_GetTreatmentValues_InputMessage"/>
<wsdl:output wsaw:Action="http://tempuri.org/IService/GetTreatmentValuesResponse" message="tns:IService_GetTreatmentValues_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IService" type="tns:IService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetTreatmentValues">
<soap:operation soapAction="http://tempuri.org/IService/GetTreatmentValues" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service">
<wsdl:port name="BasicHttpBinding_IService" binding="tns:BasicHttpBinding_IService">
<soap:address location="http://192.168.2.7:90/Service.svc"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
My android
private final String NAMESPACE="http://tempuri.org/";
private final String SOAPACTION="http://tempuri.org/GetTreatmentValues";
private final String METHODNAME="GetTreatmentValues";
private final String URL="http://192.168.2.7:90/IService/Service.svc?singleWsdl";
private EditText text1;
private EditText text2;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.tansiyon);
Button button1=(Button) findViewById(R.id.button1);
text1 = (EditText) findViewById(R.id.editText1);
text2 = (EditText) findViewById(R.id.editText2);
button1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
SoapObject request = new SoapObject(NAMESPACE,METHODNAME);
request.addProperty("tID",1);
SoapSerializationEnvelope sp = new SoapSerializationEnvelope(SoapEnvelope.VER12);
sp.dotNet = true;
sp.setOutputSoapObject(request);
HttpTransportSE aht = new HttpTransportSE(URL);
try {
aht.call(SOAPACTION,sp);
text2.setText("test");
} catch (Exception ex) {
// TODO: handle exception
text2.setText("error");
ex.printStackTrace();
}
}
});
}
first off, I assume you didn't forget to add suitable permissions in your app's manifest.
now you have a couple of problems, first you are trying network access in the UI thread which is not allowed by Android for API 12 and up, I expect a "network on main thread exception" to appear in your LogCat. You just have to move the ksoap2 call to an AsyncTask or so.
the other problem which I faced before is that I didn't specify a namespace in my wcf web service, so tempuri.org is put by default and it was not working, I had to change it to something else and use it and then it worked like a charm.
try to solve the first problem and run the app, you may not have a problem with tempuri.org but if it still crash then change the namespace in your service, publish it and run your app again.
In the android code don't append ?WSDL. Just write address up to Service.svc or you can copy the address from <soap:address location="..."/> tag of WSDL file. I hope it might work for you.
Refer the following link for further details:
http://techzusiastic.blogspot.in/2014/11/solved-xmlpullparse-error-problem-while.html
Related
I am attempting to write a Windows Desktop App (using WCF) that is a consumer of a web service.
The application:
Sends a SOAP message to a British Government Server to get an authentication token based on the arugments passed
Retrieves a response from that server in the form of a string which contains the authentication token.
I have a template of the SOAP message from the British Government, and a WSDL file for the service.
What I have tried
Add a service reference using the WSDL file. I received the following error: URI formats are not supported.
Add a Web Reference using the URL of the service. I received the following error: The request failed with HTTP status 405: Method Not Allowed.
Send the SOAP request using a POST. The Call to GetResponse() threw a 500 External Server Error.
NOTE: I am using VS 2005
WSDL:
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:conv="http://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:jms="http://www.openuri.org/2002/04/wsdl/jms/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s1="https://tpvs.hmrc.gov.uk/dpsauthentication" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="https://tpvs.hmrc.gov.uk/dpsauthentication">
<types>
<s:schema elementFormDefault="qualified" targetNamespace="https://tpvs.hmrc.gov.uk/dpsauthentication" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns="https://tpvs.hmrc.gov.uk/dpsauthentication">
<s:element name="DPSrequestToken">
<s:complexType>
<s:sequence>
<s:element name="version" type="s:int"/>
<s:element name="vendorID" type="s:string" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="DPSrequestTokenResponse">
<s:complexType>
<s:sequence>
<s:element name="DPSrequestTokenResult" type="s:string" minOccurs="0"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</types>
<message name="DPSrequestTokenSoapIn">
<part name="parameters" element="s1:DPSrequestToken"/>
</message>
<message name="DPSrequestTokenSoapOut">
<part name="parameters" element="s1:DPSrequestTokenResponse"/>
</message>
<portType name="dpsauthenticationSoap">
<operation name="DPSrequestToken">
<input message="s1:DPSrequestTokenSoapIn"/>
<output message="s1:DPSrequestTokenSoapOut"/>
</operation>
</portType>
<binding name="dpsauthenticationSoap" type="s1:dpsauthenticationSoap">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="DPSrequestToken">
<soap:operation soapAction="https://tpvs.hmrc.gov.uk/dpsauthentication/DPSrequestToken" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="dpsauthentication">
<port name="dpsauthenticationSoap" binding="s1:dpsauthenticationSoap">
<soap:address location="https://dps.ws.hmrc.gov.uk/dpsauthentication/service"/>
</port>
</service>
</definitions>
SOAP:
<!-- v1.1 30/11/2007 -->
<!-- 24/10/2011 - minor change to remove duplicated text from <Envelope> element. No impact on validation, therefore not re-versioned. -->
<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">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>as advised by SDS team</wsse:Username>
<wsse:Password>as advised by SDS team</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:DPSrequestToken xmlns:m="https://tpvs.hmrc.gov.uk/dpsauthentication">
<m:version>1</m:version>
<m:vendorID>your 4 digit vendorID</m:vendorID>
</m:DPSrequestToken>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In case someone else runs across the same issue, I was able to solve this issue by using the WSDL.exe program that is normally found in 2. C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\.
This program creates a proxy class for a web service that allows you to call the API's methods localy in your code.
In command line WSDL.exe is called like this: 3.
wsdl http://host/web_service/web_service.asmx?WSDL
I am new to WCF and I wrote some service in wcf. It is now published on the Intranet and some applications are already using that service. At the moment, I have to make the documentation about the input parameters / data type and output parameters for other developers. It is ok, if we use .Net platform to consume the service. It automatically creates the services/classes in the WebReferences folder and Intellisense work perfectly.
But if the user is using PHP or classic ASP, it doesn't work that way. They have to know exact name, type of the parameters and I have to document the services very carefully.
By using WSDL as below: how can we know the datatype and parameters of the service we want to use? If it doesn't show in WSDL, where should I look at these information? If someone gave me WCF service without documentation, how could I know how to use that service?
Thanks very much.
This following is my Interface about the Service
[ServiceContract]
public interface IEmail
{
[OperationContract]
bool InsertEmail(string Subject, string SentFrom, string SentTo, int ApplicationID, int TemplateID, string DataText);
}
The following is the exact WSDL info about my service.
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions name="Email" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
- <wsdl:types>
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
- <wsdl:message name="IEmail_InsertEmail_InputMessage">
<wsdl:part name="parameters" element="tns:InsertEmail" />
</wsdl:message>
- <wsdl:message name="IEmail_InsertEmail_OutputMessage">
<wsdl:part name="parameters" element="tns:InsertEmailResponse" />
</wsdl:message>
- <wsdl:portType name="IEmail">
- <wsdl:operation name="InsertEmail">
<wsdl:input wsaw:Action="http://tempuri.org/IEmail/InsertEmail" message="tns:IEmail_InsertEmail_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IEmail/InsertEmailResponse" message="tns:IEmail_InsertEmail_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="BasicHttpBinding_IEmail" type="tns:IEmail">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="InsertEmail">
<soap:operation soapAction="http://tempuri.org/IEmail/InsertEmail" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="Email">
- <wsdl:port name="BasicHttpBinding_IEmail" binding="tns:BasicHttpBinding_IEmail">
<soap:address location="http://myservice/Email.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
If you mean that you can't see all the types your service uses in the WSDL, this is because the WSDL WCF creates is often (maybe always) split into several bits. These other bits are linked to from the main WSDL.
So if you browse to http://myservice/Email.svc?wsdl, you'll see the WSDL you've put in your question. In here, you can see links to two other schemas - http://myservice/Email.svc?xsd=xsd0 and http://myservice/Email.svc?xsd=xsd1. If you browse to these, you'll find the type information you're looking for.
I am using Visual studio 2008 C# Windows application to connect to a webservice created by an external company. The service is a WSDL url, which is a basic soap request and response. I have inported the service as a service reference. I can call the service, and receive no errors, but the reponse is nothing. When monitoring the soap request and response in Fiddler, i see a response coming back, but it's as if VS cannot interpret the response. I have looked at creating xsd's, but get an error stating that there's already a schema. So I am at a total loss. I hope someone can help. I apologise if this exact issue has been solved before, but i cannot find anything that resolves my problem.
Thanks in advance!
The code I am using to connect to the service is as follows:
ServiceReference1.bpm bbb = new TestingWSDL.ServiceReference1.bpm();
ServiceReference1.BPMExternalAppServicesV001Client soapClient = new TestingWSDL.ServiceReference1.BPMExternalAppServicesV001Client();
ServiceReference1.DownloadShipmentDataV001 req = new TestingWSDL.ServiceReference1.DownloadShipmentDataV001();
ServiceReference1.DownloadShipmentDataV001Response resp = new TestingWSDL.ServiceReference1.DownloadShipmentDataV001Response();
try
{
soapClient.DownloadShipmentDataV001(req,out resp);
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
the response object does not have any data in. I cannot post an image, as i am not allowed.
The WSDL is quite long and is as follows:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tns="http://schemas.ccc.com/AROPInventory/bpm/external" xmlns:inst="http://schemas.aaa.com/bpm/instance/1.0" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="BPMExternalAppServicesV001" targetNamespace="http://schemas.ccc.com/AROPInventory/bpm/external" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns:tns1="http://schemas.ccc.com/AROPInventory/bpm/external" xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.argility.com/AROPInventory/bpm/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://schemas.aaa.com/bpm/instance/1.0" />
<xsd:element name="UploadShipmentDataV001">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns1:Shipments" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" name="Shipments">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Shipment">
<xsd:complexType>
<xsd:sequence>
<xs:element name="ShipmentNumber" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
<xsd:element name="Cartons">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Carton">
<xsd:annotation>
<xsd:documentation>0:not damaged 1:damaged 2: Rejected0:not damaged 1:damaged 2: Rejected0:not damaged 1:damaged 2: Rejected</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xs:element name="CartionID" type="xs:byte" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
<xs:element name="Status" type="xs:byte" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="TestUploadShipMentV001">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns1:Shipments" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="TestUploadShipMentV001Response" />
<xsd:element name="UploadShipmentDataV001Response" />
<xsd:element name="DownloadShipmentDataV001">
<xsd:complexType>
<xsd:sequence />
</xsd:complexType>
</xsd:element>
<xsd:element name="DownloadShipmentDataV001Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns1:Shipments" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.aaa.com/bpm/instance/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="bpm">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="instance_id" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="DownloadShipmentDataV001Input">
<wsdl:part name="body" element="tns:DownloadShipmentDataV001" />
</wsdl:message>
<wsdl:message name="DownloadShipmentDataV001Output">
<wsdl:part name="body" element="tns:DownloadShipmentDataV001Response" />
</wsdl:message>
<wsdl:message name="HeaderOutput">
<wsdl:part name="BPMHeader" element="inst:bpm" />
</wsdl:message>
<wsdl:portType name="BPMExternalAppServicesV001">
<wsdl:operation name="DownloadShipmentDataV001">
<wsdl:input message="tns:DownloadShipmentDataV001Input" />
<wsdl:output message="tns:DownloadShipmentDataV001Output" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BPMExternalAppServicesV001" type="tns:BPMExternalAppServicesV001">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="DownloadShipmentDataV001">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
<soap:header message="tns:HeaderOutput" part="BPMHeader" use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="BPMExternalAppServicesV001Service">
<wsdl:port name="BPMExternalAppServicesV001Port" binding="tns:BPMExternalAppServicesV001">
<soap:address location="http://aaa/aaa/com.eibus.web.soap.Gateway.wcp?organization=o=system,cn=aaa,cn=aaa,o=ho.bbb.co.za" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The fiddler response is as follows:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://schemas.aaa.com/General/1.0/">
<sender>
<reply-to>
cn=Business Process Management,cn=Business Process Management,cn=soap nodes,o=system,cn=aaa,cn=aaa20,o=ho.bbb.co.za
</reply-to>
<organizationalContext>o=system,cn=aaa,cn=aaa20,o=ho.bbb.co.za</organizationalContext>
<component>cn=Business Process Management,cn=soap nodes,o=system,cn=aaa,cn=aaa20,o=ho.bbb.co.za</component>
</sender>
<receiver>
<component>cn=webgateway#poc-aaa,cn=aaa,cn=aaa20,o=ho.bbb.co.za</component>
<sent-to xmlns="http://schemas.aaa.com/General/1.0/">socket://poc-aaa:20379/</sent-to>
</receiver>
<msg-id>00505680-004E-11E1-FBF1-7CB604BB1FC0</msg-id>
</header>
<bpm xmlns="http://schemas.aaa.com/bpm/instance/1.0">
<instance_id>26c34038-bea4-459c-a0ad-86b462ae90cb</instance_id>
</bpm>
</s:Header>
<s:Body>
<DownloadShipmentDataV001Response 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" xmlns="http://schemas.argility.com/AROPInventory/bpm/external">
<Shipments 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" xmlns="http://schemas.argility.com/AROPInventory/bpm/external">
<ShipmentHeader>
<ShipmentNumber>S001</ShipmentNumber>
<ReceivingBranch>B000028</ReceivingBranch>
<SendingBranch>B000001</SendingBranch>
<ExpectedDate>2012/07/30</ExpectedDate>
<TotalNrOfCartons>2</TotalNrOfCartons>
<ShipmentStatus>E</ShipmentStatus>
<Cartons>
<Carton>
<CartonHeader>
<NrOfItems>2</NrOfItems>
<CartionID>99</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12345</SKU>
<Description>abc</Description>
<SerialNumber>6789</SerialNumber>
<QtySent>20</QtySent>
<QtyReceived/>
</CartonDetail>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
<Carton>
<CartonHeader>
<NrOfItems>2</NrOfItems>
<CartionID>100</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12345</SKU>
<Description>abc</Description>
<SerialNumber>6789</SerialNumber>
<QtySent>20</QtySent>
<QtyReceived/>
</CartonDetail>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
</Cartons>
</ShipmentHeader>
<ShipmentHeader>
<ShipmentNumber>S002</ShipmentNumber>
<ReceivingBranch>B000029</ReceivingBranch>
<SendingBranch>B000002</SendingBranch>
<ExpectedDate>2012/06/3</ExpectedDate>
<TotalNrOfCartons>21</TotalNrOfCartons>
<ShipmentStatus>E</ShipmentStatus>
<Cartons>
<Carton>
<CartonHeader>
<NrOfItems>3</NrOfItems>
<CartionID>91</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12345</SKU>
<Description>abc</Description>
<SerialNumber>6789</SerialNumber>
<QtySent>20</QtySent>
<QtyReceived/>
</CartonDetail>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
<Carton>
<CartonHeader>
<NrOfItems>1</NrOfItems>
<CartionID>97</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
</Cartons>
</ShipmentHeader>
</Shipments>
</DownloadShipmentDataV001Response>
</s:Body>
</s:Envelope>
Thanks for posting the response as collected by Fiddler. I am actually seeing more than one problem in the WSDL and in the response conformance to the WSDL datatypes.
First issue: WSDL consistency/completeness
Note that the input and output messages refer to tns:DownloadShipmentDataV001 and tns:DownloadShipmentDataV001Response, respectively. xmlns:tns="http://schemas.ccc.com/AROPInventory/bpm/external" is the relevant prefix:namespace binding in the context of the message definitions, thus the fully-qualified names of the request and response message elements are {http://schemas.ccc.com/AROPInventory/bpm/external}DownloadShipmentDataV001 and {http://schemas.ccc.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response, respectively.
By virtue of the targetNamespace="http://schemas.argility.com/AROPInventory/bpm/external" declaration, the fully-qualified name of the elements defined in the types section of the WSDL document are
{http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001 and {http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response. This is a problem because the actual types referred to in the message definitions are missing from the WSDL and any imported/included documents.
A stub generator should complain about this when trying to consume the WSDL.
The external company should really correct this issue, but you could copy the WSDL and make a tweak by declaring the namespace of the actual element from the types section and binding to a prefix, then using that prefix in the message definition (weakness being you have an extra step in keeping up with any changes in their service definition):
xmlns:fromtype="http://schemas.argility.com/AROPInventory/bpm/external"
...
<wsdl:message name="DownloadShipmentDataV001Input">
<wsdl:part name="body" element="fromtype:DownloadShipmentDataV001" />
</wsdl:message>
<wsdl:message name="DownloadShipmentDataV001Output">
<wsdl:part name="body" element="fromtype:DownloadShipmentDataV001Response" />
</wsdl:message>
Second issue: Response Message Does Not Match Schema
Assume that the WSDL was consistent and called out the fully-qualified datatype from the types section. The response message's fully-qualified element structure would then be expected to be something like:
{http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response
{http://schemas.argility.com/AROPInventory/bpm/external}Shipments
{http://schemas.argility.com/AROPInventory/bpm/external}Shipment
{http://schemas.argility.com/AROPInventory/bpm/external}ShipmentNumber
{http://schemas.argility.com/AROPInventory/bpm/external}Cartons
{http://schemas.argility.com/AROPInventory/bpm/external}Carton
...
However, the actual structure in the response message is:
{http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response
{http://schemas.argility.com/AROPInventory/bpm/external}Shipments
{http://schemas.argility.com/AROPInventory/bpm/external}ShipmentHeader
{http://schemas.argility.com/AROPInventory/bpm/external}ShipmentNumber
...
Note that ShipmentHeader is never declared as an element in the WSDL types section and is not imported from another document. If the unmarshaller is using the datatype definition provided in the WSDL, it does not understand the ShipmentHeader or its subelements so probably would leave those out (as you are seeing).
The correction for this issue is to match up the datatype schema definition with the actual response from the service. Again, the external organization hosting the service should correct this (their service is not in compliance with the given WSDL), but you could again tweak locally with the same caveat about extra steps keeping 'your' wsdl in lock-step with their service.
I hope this helps and respond back with further questions.
You will still need to parse this XML file yourself.
We have a similar problem with IBM's Remedy software. Basically it is terrible software and this behavior should be expected. Even if they update the code to match they are not generating the WSDL from the actual XML document they are generating... this problem will continue until they change their methods and you have no control over that.
I had a similar problem with empty answer but in fiddler it said the opposite. I fixed it by removing the
`System.ServiceModel.XmlSerializerFormatAttribute attribute and was able to serialize the response. Not the optimal solution but it worked for me.
I am trying to consume the following WSDL in VS2010 and Im running into errors which seem to be specific to the WSDL.
I am adding it as a Web Service Reference, and initially no proxy classes or anything are created - the wizard completes successfully and I get a .wsdl and a Reference.map file under ~/Web References/ in the project, however the service is unavailable in code.
If I do an "Update Web Reference" on it, I get the following error:
Custom tool error: Unable to import WebService/Schema. The element attribute is not allowed on encoded message parts. The erroneous part is named 'textReturnObject' in message 'singleTextResponse'. (File: Reference.map line 1 column 1)
If I try and rename "element" to "type" i get a whole bunch of other issues:
The custom tool 'MSDiscoCodeGenerator' failed. Cannot find definition for http://schemas.xmlsoap.org/wsdl/:exampleServiceNameBinding. Service Description with namespace http://schemas.xmlsoap.org/wsdl/ is missing.
Parameter name: name
Can anyone shed any light on it? I've put the WSDL through some online tools and they consume it fine - does VS2010 have an issue with certain types of WSDL?
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.com/exampleServiceName" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="exampleServiceName" targetNamespace="http://www.example.com/exampleServiceName" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<xsd:complexType name="exampleType">
<sequence>
<element minOccurs="1" maxOccurs="1" name="title" type="string" />
<element minOccurs="1" maxOccurs="1" name="url" type="string" />
<element minOccurs="1" maxOccurs="1" name="description" type="string" />
</sequence>
</xsd:complexType>
<wsdl:types />
<wsdl:message name="singleTextRequest">
<wsdl:part name="intIdentity" type="xsd:integer" />
</wsdl:message>
<wsdl:message name="singleTextResponse">
<wsdl:part name="textReturnObject" element="wsdl:exampleType" />
</wsdl:message>
<wsdl:portType name="exampleServiceNamePortType">
<wsdl:operation name="singleTextAdvert">
<wsdl:input message="tns:singleTextRequest" />
<wsdl:output message="tns:singleTextResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="exampleServiceNameBinding" type="tns:exampleServiceNamePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
<wsdl:operation name="singleText">
<soap:operation soapAction="urn:xmethods-delayed-quotes#singleText" />
<wsdl:input>
<soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="exampleServiceNameService">
<wsdl:port name="exampleServiceNamePort" binding="wsdl:exampleServiceNameBinding">
<soap:address location="http://www.example.com/exampleServiceName/Server.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I have a question on SO where I had trouble adding a service reference. I ended up using svcutil as recommended and it solved the problem. My situation was slightly different, but it's worth a try.
.net web service: Can't add service reference, only web reference
Yes, VS2010 can't create a web service reference from some WSDLs. Have to write custom wrapper for those. OR edit your WSDL in a way so VS can consume it. For example it may be ok for you to remove web service method references for the methods that you are not planning to use if those references create trouble for you.
I'm currently in the process of creating a WCF webservice which should be compatible with WS-I Basic Profile 1.1. I'm using a wsdl-first approach (actually for the first time), defining first the xsd for the complex types, the WSDL and then using svcutil.exe for generating the according server as well as client-side interfaces/proxies. So far everything works fine. Then I decided to add a fault to my WSDL.
Regenerating with svcutil succeeded, but then I noticed that my generated fault doesn't have the properties I defined in my xsd file (which is imported by my WSDL).
complex data type xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://myprod.services.mycompany.com/groups_v1.xsd"
targetNamespace="http://myprod.services.mycompany.com/groupsfault_v1.xsd">
<xsd:complexType name="groupsFault">
<xsd:sequence>
<xsd:element name="code" type="xsd:int"/>
<xsd:element name="message" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Fault XSD definition
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://myprod.services.mycompany.com/groups_v1.xsd"
targetNamespace="http://myprod.services.mycompany.com/groups_v1.xsd">
<xsd:complexType name="group">
<xsd:sequence>
<xsd:element name="groupDescD" type="xsd:string" />
<xsd:element name="groupDescI" type="xsd:string" />
<xsd:element name="groupProtNr" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
WSDL using both of the above XSDs
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions name="Groups_v1.wsdl"
targetNamespace="http://myprod.services.mycompany.com/groups_v1.wsdl"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://myprod.services.mycompany.com/groups_v1.wsdl"
xmlns:fault="http://myprod.services.mycompany.com/groupsfault_v1.xsd"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xsd:schema targetNamespace="http://myprod.services.mycompany.com/groups_v1.wsdl"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:groups="http://myprod.services.mycompany.com/groups_v1.xsd">
<import namespace="http://myprod.services.mycompany.com/groups_v1.xsd" schemaLocation="./Groups.xsd"/>
<import namespace="http://myprod.services.mycompany.com/groupsfault_v1.xsd" schemaLocation="./GroupsFault.xsd"/>
<xsd:element name="getGroupList">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="StationProtNr" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="getGroupListResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="group" type="groups:group" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="groupsFault">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="groupsFault" type="fault:groupsFault"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="getGroupList">
<wsdl:part element="tns:getGroupList" name="parameters" />
</wsdl:message>
<wsdl:message name="getGroupListResponse">
<wsdl:part element="tns:getGroupListResponse" name="parameters" />
</wsdl:message>
<wsdl:message name="groupsFault">
<wsdl:part name="parameters" element="tns:groupsFault" />
</wsdl:message>
<wsdl:portType name="Groups_v1">
<wsdl:operation name="getGroupList">
<wsdl:input name="getGroupList" message="tns:getGroupList"/>
<wsdl:output name="getGroupListResponse" message="tns:getGroupListResponse"/>
<wsdl:fault name="getGroupListFault" message="tns:groupsFault" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Groups_v1_SOAPBinding" type="tns:Groups_v1">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="getGroupList">
<soap:operation soapAction="http://myprod.services.mycompany.com/groups_v1/getGroupList" />
<wsdl:input name="getGroupList">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="getGroupListResponse">
<soap:body use="literal" />
</wsdl:output>
<wsdl:fault name="getGroupListFault">
<soap:fault name="getGroupListFault" use="literal"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="getGroupList">
<wsdl:port binding="tns:Groups_v1_SOAPBinding" name="GroupsSOAP">
<soap:address location="http://myprod.services.mycompany.com/groups_v1" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Generated .Net fault object
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[System.Xml.Serialization.XmlSchemaProviderAttribute("ExportSchema")]
[System.Xml.Serialization.XmlRootAttribute(IsNullable=false)]
public partial class groupFault : object, System.Xml.Serialization.IXmlSerializable
{
private System.Xml.XmlNode[] nodesField;
private static System.Xml.XmlQualifiedName typeName = new System.Xml.XmlQualifiedName("groupFault", "http://sicp.services.siag.it/groups_v1.wsdl");
public System.Xml.XmlNode[] Nodes
{
get
{
return this.nodesField;
}
set
{
this.nodesField = value;
}
}
public void ReadXml(System.Xml.XmlReader reader)
{
this.nodesField = System.Runtime.Serialization.XmlSerializableServices.ReadNodes(reader);
}
public void WriteXml(System.Xml.XmlWriter writer)
{
System.Runtime.Serialization.XmlSerializableServices.WriteNodes(writer, this.Nodes);
}
public System.Xml.Schema.XmlSchema GetSchema()
{
return null;
}
public static System.Xml.XmlQualifiedName ExportSchema(System.Xml.Schema.XmlSchemaSet schemas)
{
System.Runtime.Serialization.XmlSerializableServices.AddDefaultSchema(schemas, typeName);
return typeName;
}
}
Is this ok?? I'd expect to have an object created that contains properties for "code" and "message" s.t. you can then throw it by using something like
...
throw new FaultException<groupFault>(new groupFault { code=100, message="error" });
...
(sorry for the lower-case type definitions, but this is generated code from the WSDL)
Why doesn't the svcutil.exe generate those properties??
Some sources on the web suggested to add the /useSerializerForFaults option of svcutil. I tried it, it doesn't work giving me an exception that the fault type is missing on the wsdl:portType declaration. Validation with several other tools succeeded however.
My command line output (maybe that helps for someone to identify any problems):
C:\>svcutil /out:IGroupsServi
ce.cs /n:*,MyCompany.MyProduct.MyModule /UseSerializerForFaults *.wsdl *.xsd
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152]
Copyright (c) Microsoft Corporation. All rights reserved.
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.Se
rviceModel.Description.XmlSerializerMessageContractImporter
Error: The datatype 'http://myprod.services.mycompany.com/groups_v1.wsdl:groupsFault' is
missing.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://myprod.services.mycompany.com/groups_v1.wsdl']/wsdl:portType[#name='Groups_v1']
Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is de
pendent on.
XPath to wsdl:portType: //wsdl:definitions[#targetNamespace='http://myprod.services.mycompany.com/groups_v1.wsdl']/wsdl:portType[#name='Groups_v1']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://myprod.services.mycompany.com/groups_v1.wsdl']/wsdl:binding[#name='Groups_v1_SOAPBinding']
Error: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is depend
ent on.
XPath to wsdl:binding: //wsdl:definitions[#targetNamespace='http://myprod.services.mycompany.com/groups_v1.wsdl']/wsdl:binding[#name='Groups_v1_SOAPBinding']
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://myprod.services.mycompany.com/groups_v1.wsdl']/wsdl:service[#name='getGroupList']/wsdl:port[#name='Gr
oupsSOAP']
Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata docu
ments did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assembl
ies. Verify that you passed all the metadata documents to the tool.
Warning: If you would like to generate data contracts from schemas make sure to
use the /dataContractOnly option.
C:\>
Any help is VERY appreciated :) thx
I can give you an example of a fault that is being correctly generated for me through svcutil (with /useSerializerForFaults):
<xsd:schema targetNamespace="http://myproduct.mycompany.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
<xsd:complexType name="MyError">
<xsd:sequence>
<!-- other stuff -->
<xsd:element name="description" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Is it possible that you are simply missing the namespace for your types?
This is the generated code:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("svcutil", "3.0.4506.2152")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://myproduct.mycompany.com/")]
public partial class MyError
{
// other stuff
private string descriptionField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 1)]
public string description
{
get
{
return this.descriptionField;
}
set
{
this.descriptionField = value;
}
}
}
And this is my full svcutil cmd line statement (note that I am generating a service reference for a given existing service - but it shouldn't make much of a difference in terms of code generation):
svcutil /t:code /out:C:\MyRepository\GeneratedCode\MyServiceReference.cs /n:*,myproduct.mycompany.servicereference /UseSerializerForFaults C:\MyRepository\*.wsdl C:\MyRepository\*.xsd /config:C:\MyRepository\GeneratedCode\MyServiceReference.config
I think your problem is that you need to add elementFormDefault="qualified" as an attribute to the xsd:schema part of your wsdl. That worked for me.